From: Adrian Cumiskey Date: Fri, 18 Jul 2008 18:02:36 +0000 (+0000) Subject: More optimizations and cleanups. X-Git-Tag: fop-1_0~376^2~128 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f7607a162821020cfd95a65412ed792027901738;p=xmlgraphics-fop.git More optimizations and cleanups. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@677983 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/render/afp/modca/ImageContent.java b/src/java/org/apache/fop/render/afp/modca/ImageContent.java index 65e312cb0..b63da87d9 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageContent.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageContent.java @@ -90,6 +90,7 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * Sets the image size parameters * resolution, hsize and vsize. + * * @param hresol The horizontal resolution of the image. * @param vresol The vertical resolution of the image. * @param hsize The horizontal size of the image. @@ -101,6 +102,7 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * Sets the image encoding. + * * @param encoding The image encoding. */ public void setImageEncoding(byte encoding) { @@ -109,6 +111,7 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * Sets the image compression. + * * @param compression The image compression. */ public void setImageCompression(byte compression) { @@ -117,6 +120,7 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * Sets the image IDE size. + * * @param size The IDE size. */ public void setImageIDESize(byte size) { @@ -125,6 +129,7 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * Sets the image IDE color model. + * * @param colorModel the IDE color model. */ public void setImageIDEColorModel(byte colorModel) { @@ -133,15 +138,14 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * Set the data of the image. + * * @param data the image data */ public void setImageData(byte[] data) { this.imageData = data; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { if (imageSizeParameter != null) { imageSizeParameter.write(os); @@ -161,9 +165,7 @@ public class ImageContent extends AbstractStructuredAFPObject { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[] { (byte)0x91, // ID @@ -173,9 +175,7 @@ public class ImageContent extends AbstractStructuredAFPObject { os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[] { (byte)0x93, // ID @@ -186,17 +186,16 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * Helper method to return the start of the image segment. + * * @return byte[] The data stream. */ private byte[] getImageDataStart(int len) { - byte[] data = new byte[] { (byte)0xFE, // ID (byte)0x92, // ID 0x00, // Length 0x00, // Length }; - byte[] l = BinaryUtils.convert(len, 2); data[2] = l[0]; data[3] = l[1]; @@ -206,6 +205,7 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * Helper method to return the image encoding parameter. + * * @return byte[] The data stream. */ private byte[] getImageEncodingParameter() { @@ -220,6 +220,7 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * Helper method to return the external algorithm parameter. + * * @return byte[] The data stream. */ private byte[] getExternalAlgorithmParameter() { @@ -246,6 +247,7 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * Helper method to return the image encoding parameter. + * * @return byte[] The data stream. */ private byte[] getImageIDESizeParameter() { @@ -259,6 +261,7 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * Helper method to return the external algorithm parameter. + * * @return byte[] The data stream. */ private byte[] getIDEStructureParameter() { diff --git a/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java b/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java index 370ec773d..0ae81996b 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java @@ -40,16 +40,10 @@ public class ImageInputDescriptor extends AbstractAFPObject { public void write(OutputStream os) throws IOException { byte[] data = new byte[45]; - - data[0] = 0x5A; - data[1] = 0x00; + copySF(data, Type.DESCRIPTOR, Category.IM_IMAGE); + + data[1] = 0x00; // length data[2] = 0x2C; - data[3] = (byte) 0xD3; - data[4] = (byte) 0xA6; - data[5] = (byte) 0x7B; - data[6] = 0x00; - data[7] = 0x00; - data[8] = 0x00; // Constant data. data[9] = 0x00; @@ -127,12 +121,12 @@ public class ImageInputDescriptor extends AbstractAFPObject { data[44] = (byte)0xFF; os.write(data); - } /** * Sets the resolution information for the raster image * the default value is a resolution of 240 dpi. + * * @param resolution The resolution value */ public void setResolution(int resolution) { diff --git a/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java b/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java index 7bdadb6b6..f015c6955 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java @@ -60,22 +60,13 @@ public class ImageRasterData extends AbstractAFPObject { /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { - byte[] data = new byte[9]; - - data[0] = 0x5A; - + copySF(data, Type.DATA, Category.IM_IMAGE); + // The size of the structured field - byte[] x = BinaryUtils.convert(rasterData.length + 8, 2); - data[1] = x[0]; - data[2] = x[1]; - - data[3] = (byte) 0xD3; - data[4] = (byte) 0xEE; - data[5] = (byte) 0x7B; - data[6] = 0x00; - data[7] = 0x00; - data[8] = 0x00; + byte[] len = BinaryUtils.convert(rasterData.length + 8, 2); + data[1] = len[0]; + data[2] = len[1]; os.write(data); os.write(rasterData); diff --git a/src/java/org/apache/fop/render/afp/modca/ImageSegment.java b/src/java/org/apache/fop/render/afp/modca/ImageSegment.java index 9a6c25ea0..5dda07557 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageSegment.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageSegment.java @@ -54,6 +54,7 @@ public class ImageSegment extends AbstractNamedAFPObject { /** * Constructor for the image segment with the specified name, * the name must be a fixed length of eight characters. + * * @param name The name of the image. */ public ImageSegment(String name) { diff --git a/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java b/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java index 13c76083f..fe6f5e1c5 100644 --- a/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java +++ b/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java @@ -47,30 +47,20 @@ public class MapCodedFont extends AbstractStructuredAFPObject { /** * The collection of map coded fonts (maximum of 254) */ - private List fontList = null; + private List/**/ fontList = new java.util.ArrayList(); /** * Constructor for the MapCodedFont */ public MapCodedFont() { - fontList = new java.util.ArrayList(); } /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { - byte[] startData = new byte[] { - 0x5A, - 0x00, // Reserved - 0x00, // Reserved - (byte)0xD3, - (byte)0xAB, // Format 2 - (byte)0x8A, - 0x00, // Reserved - 0x00, // Reserved - 0x00, // Reserved - }; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + byte[] startData = new byte[9]; + copySF(startData, Type.MAP, Category.CODED_FONT); baos.write(startData); Iterator iter = fontList.iterator(); diff --git a/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java b/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java index 67dcaa74f..ce5a9233f 100644 --- a/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java +++ b/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java @@ -80,11 +80,7 @@ public class MapPageOverlay extends AbstractAFPObject { } } - /** - * Accessor method to write the AFP datastream for the Map Page Overlay - * @param os The stream to write to - * @throws java.io.IOException if an I/O exception occurred - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { int oLayCount = getOverlays().size(); int recordlength = oLayCount * 18; @@ -102,8 +98,8 @@ public class MapPageOverlay extends AbstractAFPObject { // Structured field ID for a MPO data[3] = (byte) 0xD3; - data[4] = (byte) 0xAB; - data[5] = (byte) 0xD8; + data[4] = (byte) Type.MAP; + data[5] = (byte) Category.PAGE_OVERLAY; data[6] = 0x00; // Reserved data[7] = 0x00; // Reserved diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java b/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java index 02d7a5f98..f27a3dee6 100644 --- a/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java @@ -32,7 +32,6 @@ import org.apache.fop.render.afp.tools.BinaryUtils; /** * The Object Area Descriptor structured field specifies the size and attributes * of an object area presentation space. - * */ public class ObjectAreaDescriptor extends AbstractDescriptor { diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java b/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java index fc9edc4b7..0ad12fb92 100644 --- a/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java +++ b/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java @@ -23,9 +23,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.render.afp.DataObjectInfo; -import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet; -import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet; import org.apache.fop.render.afp.tools.BinaryUtils; /** @@ -41,9 +38,6 @@ public class ObjectContainer extends AbstractNamedAFPObject /*implements DataObj /** the object data */ private byte[] objectData = null; -// /** the data object info */ -// private DataObjectInfo dataObjectInfo; - /** * Default constructor */ @@ -69,35 +63,6 @@ public class ObjectContainer extends AbstractNamedAFPObject /*implements DataObj this.dataObj = dataObj; } -// /** {@inheritDoc} */ -// public AbstractNamedAFPObject getDataObject() { -// return this.dataObj; -// } -// -// /** {@inheritDoc} */ -// public DataObjectInfo getDataObjectInfo() { -// return this.dataObjectInfo; -// } - -// /** {@inheritDoc} */ -// public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { -// this.dataObjectInfo = dataObjectInfo; -// -// Registry registry = Registry.getInstance(); -// Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo); -// if (objectType != null) { -// super.setObjectClassification( -// ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT, -// objectType); -// } else { -// log.warn("no object type for " + dataObjectInfo.getUri()); -// } -// super.setFullyQualifiedName( -// FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, -// FullyQualifiedNameTriplet.FORMAT_CHARSTR, -// dataObjectInfo.getUri()); -// } - /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { // create object data from data object @@ -122,8 +87,7 @@ public class ObjectContainer extends AbstractNamedAFPObject /*implements DataObj // write out object data in chunks of object container data for (int i = 0; i <= objectData.length; i += ObjectContainerData.MAX_DATA_LEN) { - ObjectContainerData objectContainerData = new ObjectContainerData(objectData, i); - objectContainerData.write(os); + new ObjectContainerData(objectData, i).write(os); } } @@ -142,32 +106,36 @@ public class ObjectContainer extends AbstractNamedAFPObject /*implements DataObj /** The maximum object container data length */ private static final int MAX_DATA_LEN = 32759; + private byte[] objData = null; + + private int startIndex; + /** * Main constructor * * @param objData the object data */ public ObjectContainerData(byte[] objData, int startIndex) { + this.objData = objData; + this.startIndex = startIndex; + } + + /** {@inheritDoc} */ + public void write(OutputStream os) throws IOException { int dataLen = MAX_DATA_LEN; if (startIndex + MAX_DATA_LEN >= objData.length) { dataLen = objData.length - startIndex - 1; } - byte[] len = BinaryUtils.convert(8 + dataLen, 2); byte[] data = new byte[9 + dataLen]; - data[0] = 0x5A; // Structured field identifier + copySF(data, Type.DATA, Category.OBJECT_CONTAINER); + + byte[] len = BinaryUtils.convert(8 + dataLen, 2); data[1] = len[0]; // Length byte 1 data[2] = len[1]; // Length byte 2 - data[3] = (byte)0xD3; // Structured field id byte 1 - data[4] = (byte)0xEE; // Structured field id byte 2 - data[5] = getCategoryCode(); // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved // copy object data chunk System.arraycopy(objData, startIndex, data, 9, dataLen); - - super.setData(data); + os.write(data); } /** {@inheritDoc} */ @@ -177,14 +145,5 @@ public class ObjectContainer extends AbstractNamedAFPObject /*implements DataObj + ")"; } - /** {@inheritDoc} */ - protected byte getCategoryCode() { - return (byte)0x92; - } - } - - /** {@inheritDoc} */ - protected byte getCategoryCode() { - return (byte)0x92; } } diff --git a/src/java/org/apache/fop/render/afp/modca/PageObject.java b/src/java/org/apache/fop/render/afp/modca/PageObject.java index c80f21deb..029c0f605 100644 --- a/src/java/org/apache/fop/render/afp/modca/PageObject.java +++ b/src/java/org/apache/fop/render/afp/modca/PageObject.java @@ -96,54 +96,6 @@ public class PageObject extends AbstractResourceGroupContainer { addObject(ipo); } -// /** -// * @return a new page segment object -// */ -// private PageSegment createPageSegment() { -// String name = PAGE_SEGMENT_NAME_PREFIX -// + StringUtils.lpad(String.valueOf(++pageSegmentCount), '0', 5); -// PageSegment pageSegment = new PageSegment(name); -// return pageSegment; -// } - -// /** -// * @return the current page segment -// */ -// private PageSegment getCurrentPageSegment() { -// if (currentPageSegment == null) { -// this.currentPageSegment = createPageSegment(); -// super.addObject(currentPageSegment); -// } -// return this.currentPageSegment; -// } -// -// private static final String PAGE_SEGMENT_NAME_PREFIX = "PSG"; - -// /** -// * Starts a new page segment and makes it current. -// */ -// public void startPageSegment() { -// getCurrentPageSegment(); -// } -// -// /** -// * Ends the current page segment. -// */ -// public void endPageSegment() { -// this.currentPageSegment = null; -// } - -// /** -// * {@inheritDoc} -// */ -// protected void addObject(AbstractAFPObject obj) { -//// if (currentPageSegment != null) { -//// getCurrentPageSegment().addObject(obj); -//// } else { -// super.addObject(obj); -//// } -// } - /** * This method will create shading on the page using the specified * coordinates (the shading contrast is controlled via the red, green blue diff --git a/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java b/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java index 75442fb08..000988a3d 100644 --- a/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java +++ b/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java @@ -96,18 +96,13 @@ public class PreprocessPresentationObject extends AbstractStructuredAFPObject { public void writeStart(OutputStream os) throws IOException { super.writeStart(os); - byte[] l = BinaryUtils.convert(19 + getTripletDataLength(), 2); byte[] data = new byte[9]; - data[0] = 0x5A; // Structured field identifier + copySF(data, Type.PROCESS, Category.DATA_RESOURCE); + + byte[] l = BinaryUtils.convert(19 + getTripletDataLength(), 2); data[1] = l[0]; // Length byte 1 data[2] = l[1]; // Length byte 1 - data[3] = (byte)0xD3; // Structured field id byte 1 - data[4] = (byte)0xAD; // Structured field id byte 2 - data[5] = (byte)0xC3; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - + os.write(data); } @@ -147,8 +142,4 @@ public class PreprocessPresentationObject extends AbstractStructuredAFPObject { super.writeContent(os); } - /** {@inheritDoc} */ - protected byte getCategoryCode() { - return (byte)0xC3; - } } diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java b/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java index 2fc1a98c3..ed72c16e6 100644 --- a/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java @@ -63,17 +63,13 @@ public class PresentationTextDescriptor extends AbstractDescriptor { /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { - byte[] data = new byte[23]; - data[0] = 0x5A; - data[1] = 0x00; + + copySF(data, Type.MIGRATION, Category.PRESENTATION_TEXT); + + data[1] = 0x00; // length data[2] = 0x16; - data[3] = (byte) 0xD3; - data[4] = (byte) 0xB1; - data[5] = (byte) 0x9B; - data[6] = 0x00; - data[7] = 0x00; - data[8] = 0x00; + data[9] = 0x00; data[10] = 0x00; @@ -99,7 +95,6 @@ public class PresentationTextDescriptor extends AbstractDescriptor { data[22] = 0x00; os.write(data); - } } \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java b/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java index baeefafd3..8b7648ad7 100644 --- a/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java +++ b/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java @@ -21,16 +21,11 @@ package org.apache.fop.render.afp.modca; import java.io.IOException; import java.io.OutputStream; -import java.util.Collection; import java.util.Iterator; -import java.util.Map; import java.util.Set; import org.apache.fop.render.afp.DataObjectCache; -import org.apache.fop.render.afp.DataObjectInfo; import org.apache.fop.render.afp.ResourceInfo; -import org.apache.fop.render.afp.ResourceLevel; -import org.apache.fop.render.afp.tools.StringUtils; /** * A Resource Group contains a set of overlays. @@ -106,24 +101,24 @@ public final class ResourceGroup extends AbstractNamedAFPObject { // return includeObj; // } - /** - * Checks if a named object is of a valid type to be added to a resource group - * - * @param namedObj a named object - * @return true if the named object is of a valid type to be added to a resource group - */ - private boolean isValidObjectType(AbstractNamedAFPObject namedObj) { - return (namedObj instanceof Overlay - || namedObj instanceof ResourceObject - || namedObj instanceof PageSegment - || namedObj instanceof GraphicsObject - || namedObj instanceof ImageObject - || namedObj instanceof ObjectContainer - || namedObj instanceof Document - // || namedObj instanceof FormMap - // || namedObj instanceof BarcodeObject - ); - } +// /** +// * Checks if a named object is of a valid type to be added to a resource group +// * +// * @param namedObj a named object +// * @return true if the named object is of a valid type to be added to a resource group +// */ +// private boolean isValidObjectType(AbstractNamedAFPObject namedObj) { +// return (namedObj instanceof Overlay +// || namedObj instanceof ResourceObject +// || namedObj instanceof PageSegment +// || namedObj instanceof GraphicsObject +// || namedObj instanceof ImageObject +// || namedObj instanceof ObjectContainer +// || namedObj instanceof Document +// // || namedObj instanceof FormMap +// // || namedObj instanceof BarcodeObject +// ); +// } /** * Add this object cache resource info to this resource group diff --git a/src/java/org/apache/fop/render/afp/modca/ResourceObject.java b/src/java/org/apache/fop/render/afp/modca/ResourceObject.java index 6894bd426..7cc5c898b 100644 --- a/src/java/org/apache/fop/render/afp/modca/ResourceObject.java +++ b/src/java/org/apache/fop/render/afp/modca/ResourceObject.java @@ -49,46 +49,7 @@ public class ResourceObject extends AbstractPreparedAFPObject { */ public void setDataObject(AbstractNamedAFPObject obj) { this.namedObject = obj; -// -// String fqn = obj.getFullyQualifiedName(); -// if (fqn != null) { -// super.setFullyQualifiedName( -// FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, -// FullyQualifiedNameTriplet.FORMAT_CHARSTR, -// fqn); -// } -// -// byte type; -// if (obj instanceof ObjectContainer) { -// type = ResourceObjectTypeTriplet.OBJECT_CONTAINER; -// } else if (obj instanceof ImageObject) { -// type = ResourceObjectTypeTriplet.IMAGE_OBJECT; -// } else if (obj instanceof GraphicsObject) { -// type = ResourceObjectTypeTriplet.GRAPHICS_OBJECT; -// } else if (obj instanceof Document) { -// type = ResourceObjectTypeTriplet.DOCUMENT_OBJECT; -// } else if (obj instanceof PageSegment) { -// type = ResourceObjectTypeTriplet.PAGE_SEGMENT_OBJECT; -// } else if (obj instanceof Overlay) { -// type = ResourceObjectTypeTriplet.OVERLAY_OBJECT; -// } else { -// throw new UnsupportedOperationException( -// "Unsupported resource object type " + obj); -// } -// getTriplets().add(new ResourceObjectTypeTriplet(type)); } - -// /** {@inheritDoc} */ -// public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { -// this.dataObjectInfo = dataObjectInfo; -// -// if (namedObject instanceof ObjectContainer) { -// Registry.ObjectType objectType = dataObjectInfo.getObjectType(); -// super.setObjectClassification( -// ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, -// objectType); -// } -// } /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { diff --git a/src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java b/src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java index 844434aff..4634e5881 100644 --- a/src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java +++ b/src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java @@ -49,72 +49,41 @@ public class TagLogicalElement extends AbstractAFPObject { /** * Name of the key, used within the TLE */ - private String tleName = null; + private String name = null; /** * Value returned by the key */ - private String tleValue = null; - - /** - * Byte representaion of the name - */ - private byte[] tleByteName = null; - - /** - * Byte representaion of the value - */ - private byte[] tleByteValue = null; + private String value = null; /** * Construct a tag logical element with the name and value specified. + * * @param name the name of the tag logical element * @param value the value of the tag logical element */ public TagLogicalElement(String name, String value) { - - this.tleName = name; - this.tleValue = value; - - try { - - this.tleByteName = name.getBytes(AFPConstants.EBCIDIC_ENCODING); - this.tleByteValue = value.getBytes(AFPConstants.EBCIDIC_ENCODING); - - } catch (UnsupportedEncodingException usee) { - - this.tleByteName = name.getBytes(); - this.tleByteValue = value.getBytes(); - log.warn( - "Constructor:: UnsupportedEncodingException translating the name " - + name); - - } - + this.name = name; + this.value = value; } - /** - * Accessor method to obtain the byte array AFP datastream for the - * TagLogicalElement. - * @param os The outputsteam stream - * @throws java.io.IOException if an I/O exception occurred - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { - byte[] data = new byte[17 + tleName.length() + tleValue.length()]; + byte[] data = new byte[17 + name.length() + value.length()]; data[0] = 0x5A; // Set the total record length byte[] rl1 - = BinaryUtils.convert(16 + tleName.length() + tleValue.length(), 2); + = BinaryUtils.convert(16 + name.length() + value.length(), 2); //Ignore first byte data[1] = rl1[0]; data[2] = rl1[1]; // Structured field ID for a TLE data[3] = (byte) 0xD3; - data[4] = (byte) 0xA0; - data[5] = (byte) 0x90; + data[4] = (byte) Type.ATTRIBUTE; + data[5] = (byte) Category.PROCESS_ELEMENT; data[6] = 0x00; // Reserved data[7] = 0x00; // Reserved @@ -122,12 +91,25 @@ public class TagLogicalElement extends AbstractAFPObject { //Use 2 triplets, attrubute name and value (the key for indexing) - byte[] rl2 = BinaryUtils.convert(tleName.length() + 4, 1); + byte[] rl2 = BinaryUtils.convert(name.length() + 4, 1); data[9] = rl2[0]; // length of the triplet, including this field data[10] = 0x02; //Identifies it as a FQN triplet data[11] = 0x0B; // GID format data[12] = 0x00; + byte[] tleByteName = null; + byte[] tleByteValue = null; + try { + tleByteName = name.getBytes(AFPConstants.EBCIDIC_ENCODING); + tleByteValue = value.getBytes(AFPConstants.EBCIDIC_ENCODING); + } catch (UnsupportedEncodingException usee) { + tleByteName = name.getBytes(); + tleByteValue = value.getBytes(); + log.warn( + "Constructor:: UnsupportedEncodingException translating the name " + + name); + } + int pos = 13; for (int i = 0; i < tleByteName.length; i++) { data[pos++] = tleByteName[i]; diff --git a/src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java b/src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java index 29ac9eb5d..c47abe9b2 100644 --- a/src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java +++ b/src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java @@ -34,6 +34,7 @@ public class TagLogicalElementBean { /** * Constructor for the TagLogicalElementBean. + * * @param key the key attribute * @param value the value attribute */ @@ -44,6 +45,7 @@ public class TagLogicalElementBean { /** * Getter for the key attribute. + * * @return the key */ public String getKey() { @@ -52,6 +54,7 @@ public class TagLogicalElementBean { /** * Getter for the value attribute. + * * @return the value */ public String getValue() {