Package htsjdk.samtools.filter

# Class AbstractJavascriptFilter<HEADER,TYPE>

java.lang.Object
htsjdk.samtools.filter.AbstractJavascriptFilter<HEADER,TYPE>

Direct Known Subclasses:
  `JavascriptSamRecordFilter`, `JavascriptVariantFilter`

public abstract class AbstractJavascriptFilter<HEADER,TYPE> extends Object
Javascript filter with HEADER type containing TYPE records. contains two static method to get a SAM Read filter or a VariantFilter. warning: tools, like galaxy, using this class are not safe because a script can access the filesystem.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Bindings`
`bindings`
javascript bindings
`static final String`
`DEFAULT_HEADER_KEY`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`AbstractJavascriptFilter(File scriptFile, HEADER header)`
constructor using a java.io.File script, compiles the script, puts 'header' in the bindings
`protected`
`AbstractJavascriptFilter(Reader scriptReader, HEADER header)`
Constructor, compiles script, put header in the bindings
`protected`
`AbstractJavascriptFilter(String scriptExpression, HEADER header)`
constructor using a java.lang.String script, compiles the script, puts 'header' in the bindings

## Method Summary

Modifier and Type
Method
Description
`protected boolean`
`accept(TYPE record)`
Evaluates this predicate on the given argument
`String`
`getHeaderKey()`
returns key used for header binding
`abstract String`
`getRecordKey()`
returns key used for record binding

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEFAULT_HEADER_KEY

public static final String DEFAULT_HEADER_KEY

See Also:
  - Constant Field Values

### bindings

protected Bindings bindings
javascript bindings

## Constructor Details

### AbstractJavascriptFilter

protected AbstractJavascriptFilter(File scriptFile, HEADER header) throws IOException
constructor using a java.io.File script, compiles the script, puts 'header' in the bindings

Throws:
  `IOException`

### AbstractJavascriptFilter

protected AbstractJavascriptFilter(String scriptExpression, HEADER header)
constructor using a java.lang.String script, compiles the script, puts 'header' in the bindings

### AbstractJavascriptFilter

protected AbstractJavascriptFilter(Reader scriptReader, HEADER header)
Constructor, compiles script, put header in the bindings

Parameters:
  `scriptReader` - reader containing the script. will be closed.
  `header` - the header to be injected in the javascript context

## Method Details

### getHeaderKey

public String getHeaderKey()
returns key used for header binding

### getRecordKey

public abstract String getRecordKey()
returns key used for record binding

### accept

protected boolean accept(TYPE record)
Evaluates this predicate on the given argument

Parameters:
  `record` - the record to test. It will be inject in the javascript context using getRecordKey()
Returns:
  true (keep) if the user script returned 1 or true, else false (reject).