Base class for all filters.
Provides common functionality applicable to all filters.
deconstitute
public static String deconstitute(Filter[] filters)
throws IOException
Returns a string serialization of the filters.
filters
- The list of filters to serialize.
- A string representation of the filters.
deserialize
public static byte[] deserialize(String string)
Convert a sequence of hexadecimal characters back into a byte array.
string
- The string to convert (must be correct hex characters).
getDescription
public abstract String getDescription()
Get the name of the filter.
- A descriptive name for the filter.
getEnclosed
protected static SubFilterList getEnclosed(Component component)
Get the enclosed sub filter list if any.
Todo: rationalize with FilterBuilder's method(s) of the same name.
component
- The component that's supposedly enclosing the list.
- The enclosed component or
null
otherwise.
getIcon
public Icon getIcon()
Get the icon for the filter.
Loads the resource specified by
getIconSpec()
as an icon.
- The icon or null if it was not found.
getIconSpec
public abstract String getIconSpec()
Get the resource name for the icon.
- The icon resource specification.
getNodeFilter
public abstract NodeFilter getNodeFilter()
Get the underlying node filter object.
- The node filter object suitable for serialization.
getSubNodeFilters
public abstract NodeFilter[] getSubNodeFilters()
Get the underlying node filter's subordinate filters.
- The node filter object's contained filters.
instantiate
public static Filter instantiate(String class_name)
Create a new filter from the class name.
class_name
- The class to instatiate.
- The constructed filter object.
newline
public static void newline(StringBuffer out)
Append a newline to the buffer.
out
- The buffer to append to.
pickle
public static byte[] pickle(Object object)
throws IOException
Serialize an object to a byte array.
object
- The object to be pickled.
reconstitute
public static Filter[] reconstitute(String string,
Parser context)
Returns the filters represented by the string.
string
- The string with serialized node filters.context
- The context from which to extract meaningful values
for GUI choices (which aren't serialized).
- The filters gleaned from the string.
serialize
public static String serialize(byte[] data)
Serialize a byte array to a String.
Convert each byte from the serialized object into a couple of hexadecimal
characters.
data
- The serialized object as a byte array.
- The string representing the serialized object.
setExpanded
public void setExpanded(boolean expanded)
Set the expanded state for the component.
This sets invisible all but the JLabel component in the
comand component.
expanded
- If true
, 'expand' this component,
otherwise 'collapse' it.
setNodeFilter
public abstract void setNodeFilter(NodeFilter filter,
Parser context)
Assign the underlying node filter for this wrapper.
filter
- The filter to wrap.context
- The parser to use for conditioning this filter.
Some filters need contextual information to provide to the user,
i.e. for tag names or attribute names or values,
so the Parser context is provided.
setSelected
public void setSelected(boolean selected)
Set the 'selected look' for the component.
selected
- If true
, 'select' this component,
otherwise 'deselect' it.
setSubNodeFilters
public abstract void setSubNodeFilters(NodeFilter[] filters)
Assign the underlying node filter's subordinate filters.
filters
- The filters to insert into the underlying node filter.
spaces
public static void spaces(StringBuffer out,
int count)
Append count spaces to the buffer.
out
- The buffer to append to.count
- The number of spaces to append.
toJavaCode
public abstract String toJavaCode(StringBuffer out,
int[] context)
Convert this filter into Java code.
Output whatever text necessary and return the variable name.
out
- The output buffer.context
- Three integers as follows:
- indent level - the number of spaces to insert at the beginning of each line
- filter number - the next available filter number
- filter array number - the next available array of filters number
- The variable name to use when referencing this filter (usually "filter" + context[1]++)
toString
public String toString()
Returns a string representation of this component and its values.
- A string representation of this component.
unpickle
public static Object unpickle(byte[] data)
throws IOException,
ClassNotFoundException
Reconstitute a serialized object.
data
- The pickled object.
- The reconstituted object.
wrap
public static Filter wrap(NodeFilter filter,
Parser context)
Returns a wrapped filter.
filter
- A filter to be wrapped by GUI components.context
- The context within which to wrap the object.
Some wrappers need context to set up useful choices for the user.