Package com.inet.report
Class Field
- java.lang.Object
-
- com.inet.report.Field
-
- All Implemented Interfaces:
NodeParser
,com.inet.report.ReferencedObject
,java.io.Serializable
- Direct Known Subclasses:
DatabaseField
,Fields.UnknownField
,FormulaField
,GroupField
,PromptField
,SortField
,SpecialField
,SQLField
,SummaryField
public abstract class Field extends java.lang.Object implements java.io.Serializable, com.inet.report.ReferencedObject, NodeParser
Field
is the superclass of the different types of fields which can be used in a report. It summarizes the properties shared by all fields. A field is dynamic content in a report, it will be evaluated at runtime and deliver static content (text, picture, ...) for each record to the element that uses the field. I.e. if you want to insert a dynamic label into your report, you have to use aFieldElement
or aText
with aFieldPart
. BothFieldElement
andFieldPart
get their content from aField
. For each kind of source there is a specialized subclass. There areSpecialField
s for contents like 'page number' and 'current date/time',DatabaseField
s for content that comes from a database,PromptField
s for content that the user will be asked for at runtime,FormulaField
s for content that is calculated by a formula, ... .
All fields are collected within the classFields
, so you can not create an instance ofField
or subclasses.
If you want to instantiate a field by name, the name of the field should start with a special character:
- no character, if the field is a
DatabaseField
- a '%', if the field is a
SqlExprField
- a '#', if the field is a
SummaryField
- a '@', if the field is a
FormulaField
- a '?', if the field is a
PromptField
- Since:
- 6.0
- See Also:
Fields
,FieldElement
,FieldPart
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Field.FieldAttributeTag
FOR INTERNAL USE ONLY
-
Field Summary
Fields Modifier and Type Field Description static int
BINARY
The constant that identifies a Binary value.static int
BOOLEAN
The constant that identifies a Boolean value.static int
CURRENCY
The constant that identifies a Currency value.static int
CURSOR
The constant that identifies a Cursor value.static int
DATABASE_FIELD
Field is a database field.static int
DATE
The constant that identifies a Date value.static int
DATETIME
The constant that identifies a DateTime value.static int
FORMULA_FIELD
Field is a formula field.static int
GROUP_NAME_FIELD
Field is a group name field.static int
NUMBER
The constant that identifies a Number value.static int
PARAMETER_FIELD
Field is a parameter field.static int
SORT_FIELD
Field is a sort field.static int
SPECIAL_FIELD
Field is a special field.static int
SQL_FIELD
Field is a sql field.static int
STRING
The constant that identifies a String value.static int
SUMMARY_FIELD
Field is a summary field.static int
TIME
The constant that identifies a Time value.static int
UNKNOWN
The constant that identifies an unspecific type.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addReferenceHolder(com.inet.report.ReferenceHolder holder)
FOR INTERNAL USE ONLYboolean
checkNameExists(java.lang.String nameToCheck)
Checks whether the string name is the property 'name' of the field.Field
duplicate(java.lang.String name)
Duplicates this field with all its settings and returns the created Field with the given name.boolean
equals(java.lang.Object obj)
protected void
extractReference(org.xml.sax.Attributes atts)
extracts the referenced field and sets it for this Field objectField
getField()
Gets the field definition element (for example, database field element, prompt field element).Group
getGroup()
Returns the group this field is associated with.java.lang.String
getName()
Returns the value of the property 'name'.java.lang.String
getPlaceholderName()
Returns the placeholder of this field including its brackets, required to use the field in formulas and sql statements.int
getRealReferenceCount()
FOR INTERNAL USE ONLYint
getReferenceHolderCount()
FOR INTERNAL USE ONLYcom.inet.report.ReferenceHolder[]
getReferenceHolders()
FOR INTERNAL USE ONLYjava.lang.String
getRefName()
Returns the value of the property 'name' with a type marker.int
getType()
Returns the value of the property 'type'.int
getValueType()
Returns the value type (or return type) of the field.
NOTE:If DefaultAttribute is used within the formula it has to be set before calling this method.int
indexOf()
Returns the index of the field in the fields set.boolean
isDOMParser()
FOR INTERNAL USE ONLY Internal method for reading report XMLboolean
isUsed()
FOR INTERNAL USE ONLYjava.lang.String
paramString()
Returns a prettified output of this field's name and type.void
parseDOM(org.w3c.dom.Node node, java.util.Map<java.lang.String,java.lang.Object> parserMap)
FOR INTERNAL USE ONLY Internal method for reading report XMLNodeParser
parseElement(com.inet.report.parser.XMLTag group, java.lang.String tag, org.xml.sax.Attributes atts, java.util.Map<java.lang.String,java.lang.Object> parserMap)
FOR INTERNAL USE ONLY Internal method for reading report XMLvoid
parseEndElement(com.inet.report.parser.XMLTag group, java.lang.String tag, java.util.Map<java.lang.String,java.lang.Object> parserMap)
FOR INTERNAL USE ONLY Internal method for reading report XMLvoid
parseText(java.lang.String text, java.util.Map<java.lang.String,java.lang.Object> parserMap)
FOR INTERNAL USE ONLY Internal method for reading report XMLvoid
removeReferenceHolder(com.inet.report.ReferenceHolder holder)
FOR INTERNAL USE ONLYvoid
rename(java.lang.String newName)
FOR INTERNAL USE ONLYprotected abstract void
saveFieldXML2(java.io.PrintWriter pw, int depth)
XML2: FOR INTERNAL USE ONLYvoid
setField(Field newField)
Sets the field definition element (for example, DatabaseField element, prompt field element).void
setGroup(Group group)
Sets the group this field should associated with.abstract void
setName(java.lang.String newValue)
Sets the value of the property 'name'.void
setValueType(int newValue)
Sets the value of the property 'value type'.protected java.lang.String
trimAwayBrackets(java.lang.String refname)
trims away "{" before and after string, e.g.
-
-
-
Field Detail
-
NUMBER
public static final int NUMBER
The constant that identifies a Number value.- See Also:
- Constant Field Values
-
CURRENCY
public static final int CURRENCY
The constant that identifies a Currency value.- See Also:
- Constant Field Values
-
BOOLEAN
public static final int BOOLEAN
The constant that identifies a Boolean value.- See Also:
- Constant Field Values
-
DATE
public static final int DATE
The constant that identifies a Date value.- See Also:
- Constant Field Values
-
TIME
public static final int TIME
The constant that identifies a Time value.- See Also:
- Constant Field Values
-
STRING
public static final int STRING
The constant that identifies a String value.- See Also:
- Constant Field Values
-
BINARY
public static final int BINARY
The constant that identifies a Binary value.- See Also:
- Constant Field Values
-
DATETIME
public static final int DATETIME
The constant that identifies a DateTime value.- See Also:
- Constant Field Values
-
CURSOR
public static final int CURSOR
The constant that identifies a Cursor value.- See Also:
- Constant Field Values
-
UNKNOWN
public static final int UNKNOWN
The constant that identifies an unspecific type.- See Also:
- Constant Field Values
-
DATABASE_FIELD
public static final int DATABASE_FIELD
Field is a database field.- See Also:
- Constant Field Values
-
FORMULA_FIELD
public static final int FORMULA_FIELD
Field is a formula field.- See Also:
- Constant Field Values
-
SUMMARY_FIELD
public static final int SUMMARY_FIELD
Field is a summary field.- See Also:
- Constant Field Values
-
SPECIAL_FIELD
public static final int SPECIAL_FIELD
Field is a special field.- See Also:
- Constant Field Values
-
GROUP_NAME_FIELD
public static final int GROUP_NAME_FIELD
Field is a group name field.- See Also:
- Constant Field Values
-
PARAMETER_FIELD
public static final int PARAMETER_FIELD
Field is a parameter field.- See Also:
- Constant Field Values
-
SORT_FIELD
public static final int SORT_FIELD
Field is a sort field.- See Also:
- Constant Field Values
-
SQL_FIELD
public static final int SQL_FIELD
Field is a sql field.- See Also:
- Constant Field Values
-
-
Method Detail
-
paramString
public java.lang.String paramString()
Returns a prettified output of this field's name and type.- Returns:
- Prettified output of this field's name and type.
- Since:
- 6.0
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getPlaceholderName
public java.lang.String getPlaceholderName()
Returns the placeholder of this field including its brackets, required to use the field in formulas and sql statements. To use a field in a formula or in a sql statement, it is necessary to put the placeholder of this field in it.- Returns:
- The placeholder of this field with its brackets, e.g. "{#mySummary}"
- Since:
- 6.0
-
getName
public java.lang.String getName()
Returns the value of the property 'name'.- Returns:
- The value of the property 'name'.
- Since:
- 6.0
- See Also:
setName(java.lang.String)
,getRefName()
-
setName
public abstract void setName(java.lang.String newValue) throws ReportException
Sets the value of the property 'name'.- Parameters:
newValue
-newValue
The new value of the property 'name'.- Throws:
ReportException
- will thrown if the name already exists or is not allowed.- Since:
- 6.0
-
getRefName
public java.lang.String getRefName()
Returns the value of the property 'name' with a type marker. This is the name that is used in formulas. For example for the formula 'abc' is the return value '@abc'.
-
getField
public Field getField()
Gets the field definition element (for example, database field element, prompt field element).- Returns:
Field
The current value of the 'field' property.- Since:
- 6.0
-
setField
public void setField(Field newField)
Sets the field definition element (for example, DatabaseField element, prompt field element).- Parameters:
newField
- The new field element of the property 'field'.- Since:
- 6.0
-
getType
public int getType()
Returns the value of the property 'type'.- Returns:
- The value of the property 'type'.
- Since:
- 6.0
- See Also:
DATABASE_FIELD
,FORMULA_FIELD
,SUMMARY_FIELD
,SPECIAL_FIELD
,GROUP_NAME_FIELD
,PARAMETER_FIELD
,SORT_FIELD
,SQL_FIELD
,DatabaseField
,FormulaField
,SummaryField
,SpecialField
,GroupField
,PromptField
,SortField
,SQLField
-
getGroup
public Group getGroup()
Returns the group this field is associated with.- Returns:
- Returns the group based on this field if there is one, else
null
. - Since:
- 6.0
- See Also:
SummaryField
,GroupField
,Group
-
setGroup
public void setGroup(Group group)
Sets the group this field should associated with. Use this method for setting the group in summary field. GroupFields are generated and initialised automatically at group creation time. You do not need to change the group reference of this fields.- Parameters:
group
- The reference to the group of this field.- Since:
- 6.0
- See Also:
SummaryField
,GroupField
,Group
-
getValueType
public int getValueType()
Returns the value type (or return type) of the field.
NOTE:If DefaultAttribute is used within the formula it has to be set before calling this method. A null-value will cause an exception here. If you don't know the exact value of the DefaultAttribute you may use a dummy-value for getValueType. The reason is that getValueType only regards the type of object not their value.
-
setValueType
public void setValueType(int newValue)
Sets the value of the property 'value type'.
-
saveFieldXML2
protected abstract void saveFieldXML2(java.io.PrintWriter pw, int depth)
XML2: FOR INTERNAL USE ONLY- Parameters:
pw
- the print writerdepth
- the current depth
-
indexOf
public int indexOf()
Returns the index of the field in the fields set. For each field type there is a separate list (DatabaseField, FormulaField, PromptField, SummaryField, SQLField, SortField, GroupField).
Note: Do not call this method for FormulaFields which are either record selection formula, group selection formula or property formulas. If the field was already removed from Engine this will return -1.- Returns:
- The index of the field in the field set of this engine or -1 if the field was already removed from the engine.
- Since:
- 6.0
- See Also:
Fields.removeDatabaseField(int)
,Fields.removeFormulaField(int)
,Fields.removePromptField(int)
,Fields.removeSummaryField(int)
,Fields.removeSQLField(int)
,Fields.removeSortField(int)
,Fields.getDatabaseField(int)
,Fields.getFormulaField(int)
,Fields.getPromptField(int)
,Fields.getSummaryField(int)
,Fields.getSQLExpressionField(int)
,Fields.getSortField(int)
-
isUsed
public boolean isUsed()
FOR INTERNAL USE ONLY- Since:
- 6.0
-
checkNameExists
public boolean checkNameExists(java.lang.String nameToCheck)
Checks whether the string name is the property 'name' of the field.- Parameters:
nameToCheck
- Name to be checked- Returns:
- true if name equals the field's property 'name'
- Since:
- 6.0
-
addReferenceHolder
public void addReferenceHolder(com.inet.report.ReferenceHolder holder)
FOR INTERNAL USE ONLY- Specified by:
addReferenceHolder
in interfacecom.inet.report.ReferencedObject
- Since:
- 6.0
-
getReferenceHolders
public com.inet.report.ReferenceHolder[] getReferenceHolders()
FOR INTERNAL USE ONLY- Specified by:
getReferenceHolders
in interfacecom.inet.report.ReferencedObject
-
getReferenceHolderCount
public int getReferenceHolderCount()
FOR INTERNAL USE ONLY- Specified by:
getReferenceHolderCount
in interfacecom.inet.report.ReferencedObject
-
getRealReferenceCount
public int getRealReferenceCount()
FOR INTERNAL USE ONLY- Specified by:
getRealReferenceCount
in interfacecom.inet.report.ReferencedObject
-
removeReferenceHolder
public void removeReferenceHolder(com.inet.report.ReferenceHolder holder)
FOR INTERNAL USE ONLY- Specified by:
removeReferenceHolder
in interfacecom.inet.report.ReferencedObject
- Since:
- 6.0
-
rename
public void rename(java.lang.String newName) throws ReportException
FOR INTERNAL USE ONLY- Throws:
ReportException
- Since:
- 6.0
-
extractReference
protected void extractReference(org.xml.sax.Attributes atts) throws ReportException
extracts the referenced field and sets it for this Field object- Parameters:
atts
- XML attributes containing "name" and "value"- Throws:
ReportException
- If there are problems setting the field- Since:
- 8.0
-
trimAwayBrackets
protected java.lang.String trimAwayBrackets(java.lang.String refname)
trims away "{" before and after string, e.g. {abc} => abc- Parameters:
refname
- name to trim- Returns:
- trimmed string
- Since:
- 8.0
-
parseElement
public NodeParser parseElement(com.inet.report.parser.XMLTag group, java.lang.String tag, org.xml.sax.Attributes atts, java.util.Map<java.lang.String,java.lang.Object> parserMap) throws FatalParserException
FOR INTERNAL USE ONLY Internal method for reading report XMLParses an XML node with the given information, and returns either a sub-element which was created as a result, or null if no sub-element was created, i.e. the information was applied to the ReportComponent itself. Note that the parsing is highly tolerant, i.e. exceptions are intercepted and suppressed if at all possible.
- Specified by:
parseElement
in interfaceNodeParser
- Parameters:
group
- XMLTag of the current node to be parsed, or null if there is no such current group. An XMLTag is a group of nodes bundled together, usually it is a Properties node such as CommonProperties, BorderProperties, etc.tag
- The XMLTag to be parsedatts
- The set of attributes in the current XMLTagparserMap
- The map of current Parser.- Returns:
- The NodeParser sub-element if one needed to be created, or null if none was created.
- Throws:
FatalParserException
- if an exception occurs which causes the report to not be able to be read: causes the abortion of the reading of the report.
-
parseText
public void parseText(java.lang.String text, java.util.Map<java.lang.String,java.lang.Object> parserMap)
FOR INTERNAL USE ONLY Internal method for reading report XMLThis method is called if text was encountered in the context of this node. (Examples would be a formula's text or a text element's text)
- Specified by:
parseText
in interfaceNodeParser
- Parameters:
text
- text encountered and to be storedparserMap
- The map of current Parser.
-
parseEndElement
public void parseEndElement(com.inet.report.parser.XMLTag group, java.lang.String tag, java.util.Map<java.lang.String,java.lang.Object> parserMap) throws FatalParserException
FOR INTERNAL USE ONLY Internal method for reading report XMLReceive notification of the end of an XML tag.
- Specified by:
parseEndElement
in interfaceNodeParser
- Parameters:
group
- XMLTag of the current node to be parsed, or null if there is no such current group.tag
- The XMLTag to be parsedparserMap
- The map of current Parser.- Throws:
FatalParserException
- if an exception occurs which causes the report to not be able to be read: causes the abortion of the reading of the report.
-
isDOMParser
public boolean isDOMParser()
FOR INTERNAL USE ONLY Internal method for reading report XMLReturns whether this node is to be read via a DOM parser.
- Specified by:
isDOMParser
in interfaceNodeParser
- Returns:
- true if this node is to be read via a DOM parser, false otherwise.
-
parseDOM
public void parseDOM(org.w3c.dom.Node node, java.util.Map<java.lang.String,java.lang.Object> parserMap) throws FatalParserException
FOR INTERNAL USE ONLY Internal method for reading report XMLParses the node.
- Specified by:
parseDOM
in interfaceNodeParser
- Parameters:
node
- the nodeparserMap
- The map of current Parser.- Throws:
FatalParserException
- if an exception occurs which causes the report to not be able to be read: causes the abortion of the reading of the report.
-
duplicate
public Field duplicate(java.lang.String name)
Duplicates this field with all its settings and returns the created Field with the given name. Note that the new formula field will not initially be referenced by any other report objects. If you duplicate a property formula, you will have to set the new formula as a separate property formula.- Parameters:
name
- the name the created field should have.- Returns:
- the duplicated field.
- Throws:
java.lang.IllegalArgumentException
- if an field with the given name already exists .java.lang.UnsupportedOperationException
- if a field which is not a FormulaField, PromptField, SQLField, or SummaryField is attempted to be duplicated- Since:
- 9.0
-
-