|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.polliwog.fields.FieldDefinition
public class FieldDefinition
Represents the information about a field, the information held in this class is used
to convert a field in a log entry to a solid sub-class of AbstractField
.
This class is configured using a XML format as defined below.
Name | Parent Element(s) | Root (Y/N) | Count | Description |
---|---|---|---|---|
field | none - root element | Y | 1 | The root element that defines a field. |
param | field | N | Unlimited | The element that defines a param that will be passed to the AbstractField.init(Map,String) method in the Map. |
Format | Description |
---|---|
string | A string value, in general this can be any combination of alpha-numeric characters. |
class | A fully-qualified class name. |
Name | Parent Element(s) | Required (Y/N) | Format | Values | Description | |
---|---|---|---|---|---|---|
openQuote | field | N | string | Any.1 | Defines the open quote value for the field. | |
closeQuote | field | N | string | Any.1 | Defines the closing quote value for the field. If the openQuote attribute is NOT specified but closeQuote IS then this value is ignored. | |
escapedBy | field | N | string | Any.1 | Defines an escape value for the openQuote and closeQuote values. | |
class | field | Y | class | Any valid fully-qualified class that extends AbstractField . |
Defines the sub-class of AbstractField that is created to represent the field value. |
|
id | param | Y | string | Any.2 | Defines the id of the parameter. | |
value | param | Y | string | Any.2 | Defines the value of the parameter. |
Utilities.getValue(StringBuffer,String,String,String)
only a single character should be used.AbstractField
sub-class should be used. The behaviour of the sub-class when it encounters init parameters that are not valid is not defined.
<!-- Define a field suitable for handling the request line of an Apache web log using the "common" format. --> <field class="org.polliwog.fields.RequestLineField" openQuote='"' closeQuote='"' escapedBy="\" /> <!-- Define a field suitable for handling the a date/time field with timezone "Australia/Brisbane". --> <field class="org.polliwog.fields.DateTimeField" openQuote="[" closeQuote="]"> <param id="timeZone" value="Australia/Brisbane" /> <param id="format" value="dd/MMM/yyyy:HH:mm:ss Z" /> </field>
Once constructed the FieldDefinition can then be used to "spawn" the
relevant AbstractField
sub-class configured with the specified parameters and
value via the buildField(String)
method.
See LogEntryFormat.createEntry(String,LogEntry)
for a common usage example.
Last Modified By: $Author: barrygently $ Last Modified On: $Date: 2005/07/04 14:00:02 $ Current Revision: $Revision: 1.3 $
AbstractField
Constructor Summary | |
---|---|
FieldDefinition(org.jdom.Element root)
Create a new FieldDefinition from a JDOM Element. |
Method Summary | |
---|---|
AbstractField |
buildField(java.lang.String val)
Construct a field using the information loaded from the Element passed to the constructor. |
java.lang.String |
getCloseQuoteToken()
Get the value used for the closing quote. |
java.lang.String |
getEscapedBy()
Get the string that is used to escape quote values. |
java.lang.String |
getOpenQuoteToken()
Get the value used for the opening quote. |
int |
getTokenCount()
|
boolean |
isBlank()
|
boolean |
isUrlDecode()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FieldDefinition(org.jdom.Element root) throws WeblogException, org.jdom.JDOMException
It should be noted that the parameters are held in the order they are listed
in the XML, this may (and probably isn't) important for classes extending
AbstractField
but it's worth knowing!
root
- The root element of the field.
WeblogException
- If a duplicate parameter id is given or if the class defined
by the class attribute cannot be loaded or that the class
is not a sub-class (directly or indirectly) of AbstractField
.
org.jdom.JDOMException
- If the structure of the JDOM element does not conform with
that defined above.Method Detail |
---|
public boolean isBlank()
public java.lang.String getEscapedBy()
public AbstractField buildField(java.lang.String val) throws WeblogException
AbstractField
.
A new instance of sub-class is first created via reflection (a no-arg constructor
is required here since Class.newInstance is used for the construction of the
new instance} then AbstractField.init(Map,String)
is called with the value
passed in and the parameters from the field definition.
val
- The value to use to init the field instance.
AbstractField
sub-class.
WeblogException
- If the new sub-class cannot be created or if
AbstractField.init(Map,String)
throws
an exception.public java.lang.String getOpenQuoteToken()
public java.lang.String getCloseQuoteToken()
public boolean isUrlDecode()
public int getTokenCount()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |