Package org.apache.fop.afp.util
Class AFPResourceUtil
- java.lang.Object
-
- org.apache.fop.afp.util.AFPResourceUtil
-
public final class AFPResourceUtil extends java.lang.Object
TODO better docs Utility for AFP resource handling A utility class to read structured fields from a MO:DCA document. Each component of a mixed object document is explicitly defined and delimited in the data. This is accomplished through the use of MO:DCA data structures, called structured fields. Structured fields are used to envelop document components and to provide commands and information to applications using the data. Structured fields may contain one or more parameters. Each parameter provides one value from a set of values defined by the architecture.
MO:DCA structured fields consist of two parts: an introducer that identifies the length and type of the structured field, and data that provides the structured field's effect. The data is contained in a set of parameters, which can consist of other data structures and data elements. The maximum length of a structured field is 32767 bytes.
-
-
Field Summary
Fields Modifier and Type Field Description private static byte
END_FIELD_ANY_NAME
private static org.apache.commons.logging.Log
LOG
private static byte
TYPE_CODE_BEGIN
private static byte
TYPE_CODE_END
-
Constructor Summary
Constructors Modifier Constructor Description private
AFPResourceUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
copyNamedResource(java.lang.String name, java.io.InputStream in, java.io.OutputStream out)
Copy a named resource to a givenOutputStream
.private static void
copyNamedStructuredFields(java.lang.String name, UnparsedStructuredField fieldBegin, MODCAParser parser, java.io.OutputStream out)
static void
copyResourceFile(java.io.InputStream in, java.io.OutputStream out)
Copy a complete resource file to a givenOutputStream
.private static boolean
fieldHasValidName(UnparsedStructuredField field, java.lang.String name)
The AFP specification states that it is valid for the end structured field to have: - No tag name specified, which will cause it to match any existing tag type match.private static boolean
fieldMatchesBeginCategoryCode(UnparsedStructuredField field, UnparsedStructuredField fieldBegin)
private static boolean
fieldMatchesEndTagType(UnparsedStructuredField field)
static byte[]
getNext(byte[] identifier, java.io.InputStream inputStream)
Get the next structured field as identified by the identifier parameter (this must be a valid MO:DCA structured field).private static java.lang.String
getResourceName(UnparsedStructuredField field)
private static boolean
isEndOfStructuredField(UnparsedStructuredField field, UnparsedStructuredField fieldBegin, java.lang.String name)
-
-
-
Field Detail
-
TYPE_CODE_BEGIN
private static final byte TYPE_CODE_BEGIN
- See Also:
- Constant Field Values
-
TYPE_CODE_END
private static final byte TYPE_CODE_END
- See Also:
- Constant Field Values
-
END_FIELD_ANY_NAME
private static final byte END_FIELD_ANY_NAME
- See Also:
- Constant Field Values
-
LOG
private static final org.apache.commons.logging.Log LOG
-
-
Method Detail
-
getNext
public static byte[] getNext(byte[] identifier, java.io.InputStream inputStream) throws java.io.IOException
Get the next structured field as identified by the identifier parameter (this must be a valid MO:DCA structured field).- Parameters:
identifier
- the three byte identifierinputStream
- the inputStream- Returns:
- the next structured field or null when there are no more
- Throws:
java.io.IOException
- if an I/O exception occurred
-
getResourceName
private static java.lang.String getResourceName(UnparsedStructuredField field) throws java.io.UnsupportedEncodingException
- Throws:
java.io.UnsupportedEncodingException
-
copyResourceFile
public static void copyResourceFile(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
Copy a complete resource file to a givenOutputStream
.- Parameters:
in
- external resource inputout
- output destination- Throws:
java.io.IOException
- if an I/O error occurs
-
copyNamedResource
public static void copyNamedResource(java.lang.String name, java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
Copy a named resource to a givenOutputStream
. The MO:DCA fields read from theInputStream
are scanned for the resource with the given name.- Parameters:
name
- name of structured fieldin
- external resource inputout
- output destination- Throws:
java.io.IOException
- if an I/O error occurs
-
copyNamedStructuredFields
private static void copyNamedStructuredFields(java.lang.String name, UnparsedStructuredField fieldBegin, MODCAParser parser, java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
isEndOfStructuredField
private static boolean isEndOfStructuredField(UnparsedStructuredField field, UnparsedStructuredField fieldBegin, java.lang.String name) throws java.io.UnsupportedEncodingException
- Throws:
java.io.UnsupportedEncodingException
-
fieldMatchesEndTagType
private static boolean fieldMatchesEndTagType(UnparsedStructuredField field)
-
fieldMatchesBeginCategoryCode
private static boolean fieldMatchesBeginCategoryCode(UnparsedStructuredField field, UnparsedStructuredField fieldBegin)
-
fieldHasValidName
private static boolean fieldHasValidName(UnparsedStructuredField field, java.lang.String name) throws java.io.UnsupportedEncodingException
The AFP specification states that it is valid for the end structured field to have: - No tag name specified, which will cause it to match any existing tag type match. - The name has FFFF as its first two bytes - The given name matches the previous structured field name- Throws:
java.io.UnsupportedEncodingException
-
-