Package org.verapdf.features.tools
Class CreateNodeHelper
java.lang.Object
org.verapdf.features.tools.CreateNodeHelper
Helps in creating similar nodes in different features objects
- Author:
- Maksim Bezrukov
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic FeatureTreeNode
addBoxFeature
(String name, double[] box, FeatureTreeNode parent) Creates feature node for boxesstatic FeatureTreeNode
addDeviceColorSpaceNode
(String name, double[] color, FeatureTreeNode parent, FeaturesObject object) Creates new node for device color spacestatic FeatureTreeNode
addNotEmptyNode
(String name, String value, FeatureTreeNode parent) Creates new node with given name and value if both of this parametrs are not nullstatic void
addWidthHeightFeatures
(double[] box, FeatureTreeNode parent) static FeatureTreeNode
createDateNode
(String nodeName, FeatureTreeNode parent, Calendar date, FeaturesObject object) Creates node with date value formatted in XML format from the given Calendarstatic String
formatDouble
(double value, int fractionDigits) static byte[]
Generates byte array with contents of a streamstatic void
parseIDSet
(Set<String> set, String elementName, String setName, FeatureTreeNode root) Creates elements with nameelementName
and attribute id with values fromset
and attach them to theroot
element in case, whensetName
is null and to the element withroot
parent and nameelementName
in other casestatic void
parseMatrix
(double[] array, FeatureTreeNode parent) static FeatureTreeNode
parseMetadata
(InputStream metadata, String nodeName, FeatureTreeNode parent, FeaturesObject object)
-
Field Details
-
ID
- See Also:
-
WIDTH
- See Also:
-
HEIGHT
- See Also:
-
-
Method Details
-
createDateNode
public static FeatureTreeNode createDateNode(String nodeName, FeatureTreeNode parent, Calendar date, FeaturesObject object) throws FeatureParsingException Creates node with date value formatted in XML format from the given Calendar- Parameters:
nodeName
- name of the created nodeparent
- parent element for created nodedate
- the given date as Calendar class- Returns:
- created node
- Throws:
FeatureParsingException
-
addBoxFeature
public static FeatureTreeNode addBoxFeature(String name, double[] box, FeatureTreeNode parent) throws FeatureParsingException Creates feature node for boxes- Parameters:
name
- name of the nodebox
- PDRectangle object represents the boxparent
- parent element for the created node- Returns:
- created node
- Throws:
FeatureParsingException
-
addWidthHeightFeatures
public static void addWidthHeightFeatures(double[] box, FeatureTreeNode parent) throws FeatureParsingException - Throws:
FeatureParsingException
-
addNotEmptyNode
public static FeatureTreeNode addNotEmptyNode(String name, String value, FeatureTreeNode parent) throws FeatureParsingException Creates new node with given name and value if both of this parametrs are not null- Parameters:
name
- name of the nodevalue
- value of the nodeparent
- parent of the node- Returns:
- generated node
- Throws:
FeatureParsingException
-
addDeviceColorSpaceNode
public static FeatureTreeNode addDeviceColorSpaceNode(String name, double[] color, FeatureTreeNode parent, FeaturesObject object) throws FeatureParsingException Creates new node for device color space- Parameters:
name
- name for the created nodecolor
- PDColor class represents device color space for creating nodeparent
- parent node for the creating nodeobject
- features object which calls this method- Returns:
- created node
- Throws:
FeatureParsingException
-
parseIDSet
public static void parseIDSet(Set<String> set, String elementName, String setName, FeatureTreeNode root) throws FeatureParsingException Creates elements with nameelementName
and attribute id with values fromset
and attach them to theroot
element in case, whensetName
is null and to the element withroot
parent and nameelementName
in other case- Parameters:
set
- set of elements idelementName
- element namessetName
- name of the parent element for created elements. If null, all created elements will be attached to theroot
root
- root element for the generated parent element for generated elements or direct paren for generated elements in case ofsetName
equals to null- Throws:
FeatureParsingException
-
parseMetadata
public static FeatureTreeNode parseMetadata(InputStream metadata, String nodeName, FeatureTreeNode parent, FeaturesObject object) throws FeatureParsingException - Throws:
FeatureParsingException
-
inputStreamToByteArray
Generates byte array with contents of a stream- Parameters:
is
- input stream for converting- Returns:
- byte array with contents of a stream
- Throws:
IOException
- If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
-
parseMatrix
public static void parseMatrix(double[] array, FeatureTreeNode parent) throws FeatureParsingException - Throws:
FeatureParsingException
-
formatDouble
-