--- /dev/null
+package org.apache.fop.rtf.rtflib.interfaces;
+
+/*-----------------------------------------------------------------------------
+ * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
+ *
+ * ====================================================================
+ * jfor Apache-Style Software License.
+ * Copyright (c) 2002 by the jfor project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed
+ * by the jfor project (http://www.jfor.org)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The name "jfor" must not be used to endorse
+ * or promote products derived from this software without prior written
+ * permission. For written permission, please contact info@jfor.org.
+ *
+ * 5. Products derived from this software may not be called "jfor",
+ * nor may "jfor" appear in their name, without prior written
+ * permission of info@jfor.org.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ * Contributor(s):
+-----------------------------------------------------------------------------*/
+
+/** Used to get information about tables, for example when handling nested tables
+ *
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+//------------------------------------------------------------------------------
+// $Id$
+// $Log$
+// Revision 1.1 2003/06/25 09:01:17 bdelacretaz
+// additional jfor packages donated to the FOP project
+//
+// Revision 1.1 2002/08/12 09:40:02 bdelacretaz
+// V0.7.1dev-e, contributions from Boris Poudérous for number-columns-spanned
+// and vertical merging of tables cells.
+//
+//------------------------------------------------------------------------------
+
+public interface ITableColumnsInfo
+{
+ float INVALID_COLUM_WIDTH = 200f;
+
+ /** reset the column iteration index, meant to be called when creating a new row */
+ void selectFirstColumn();
+
+ /** increment the column iteration index */
+ void selectNextColumn();
+
+ /** get current column width according to column iteration index
+ * @return INVALID_COLUMN_WIDTH if we cannot find the value
+ */
+ float getColumnWidth();
+
+ /** return current column iteration index */
+ int getColumnIndex();
+
+ /** return number of columns */
+ int getNumberOfColumns();
+}
\ No newline at end of file
--- /dev/null
+package org.apache.fop.rtf.rtflib.tools;
+
+import java.io.IOException;
+import org.w3c.dom.*;
+import org.xml.sax.*;
+import org.xml.sax.helpers.AttributesImpl;
+
+/*-----------------------------------------------------------------------------
+ * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
+ *
+ * ====================================================================
+ * jfor Apache-Style Software License.
+ * Copyright (c) 2002 by the jfor project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed
+ * by the jfor project (http://www.jfor.org)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The name "jfor" must not be used to endorse
+ * or promote products derived from this software without prior written
+ * permission. For written permission, please contact info@jfor.org.
+ *
+ * 5. Products derived from this software may not be called "jfor",
+ * nor may "jfor" appear in their name, without prior written
+ * permission of info@jfor.org.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ * Contributor(s):
+ * Thanks to John Cowan (cowan@ccil.org) for his DomParser class on which parts
+ * of this are based. <br>
+-----------------------------------------------------------------------------*/
+
+/** Walks a DOM document and fires (some) SAX events to simulate parsing
+ * of the original document. <br>
+ * Written to use jfor with Cocoon 1.8. <br>
+ * Only SAX events that are used by the jfor Converter class are implemented. <br>
+ * Namespace URIs and local names are not implemented. <br>
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+//------------------------------------------------------------------------------
+// $Id$
+// $Log$
+// Revision 1.1 2003/06/25 09:01:17 bdelacretaz
+// additional jfor packages donated to the FOP project
+//
+// Revision 1.4 2002/07/12 08:08:31 bdelacretaz
+// License changed to jfor Apache-style license
+//
+// Revision 1.3 2001/08/31 07:51:01 bdelacretaz
+// MPL license text added + javadoc class comments corrected
+//
+// Revision 1.2 2001/08/30 10:21:50 bdelacretaz
+// Converter modified to be usable as a pure SAX ContentHandler for Cocoon 2 integration
+// (thanks to Gianugo Rabellino, gianugo@rabellino.it)
+//
+// Revision 1.1 2001/08/29 13:27:51 bdelacretaz
+// V0.4.1 - base package name changed to org.apache.fop.rtf.rtflib.jfor
+//
+// Revision 1.1.1.1 2001/08/02 12:53:48 bdelacretaz
+// initial SourceForge checkin of V0.1 code
+//
+//------------------------------------------------------------------------------
+
+public class DomToSaxAdapter
+extends ElementVisitor
+{
+ private ContentHandler m_handler;
+ private final Document m_doc;
+
+ /** create an adapter for the given DOM Document */
+ public DomToSaxAdapter(Document doc)
+ {
+ m_doc = doc;
+ }
+
+ /** walk the document and send SAX events to the given ContentHandler */
+ public void simulateParsing(ContentHandler ch) throws IOException,SAXException
+ {
+ m_handler = ch;
+ this.visit(m_doc.getDocumentElement());
+ m_handler.endDocument();
+ }
+
+ /** called at the start of the visit of an Element */
+ protected void startElement(Element e) throws IOException,SAXException
+ {
+ m_handler.startElement(null,null,e.getTagName(),saxAttributes(e.getAttributes()));
+ }
+
+ /** called at the end of the visit of an Element */
+ protected void endElement(Element e) throws IOException,SAXException
+ {
+ m_handler.endElement(null,null,e.getTagName());
+ }
+
+ /** called to visit a Text node */
+ protected void visitText(Text t) throws IOException,SAXException
+ {
+ final String data = t.getNodeValue();
+ final int datalen = data.length();
+ final char [] array = new char[datalen];
+ data.getChars(0, datalen, array, 0);
+ m_handler.characters(array, 0, datalen);
+ }
+
+ /** called to visit a CDATASection node */
+ protected void visitCDATA(CDATASection cds) throws IOException
+ {
+ // not needed by jfor
+ }
+
+ /** called to visit a Comment node */
+ protected void visitComment(Comment c) throws IOException
+ {
+ // not needed by jfor
+ }
+
+ /** called to visit a Node that is not of the other types */
+ protected void visitNode(Node n) throws IOException
+ {
+ // not needed by jfor
+ }
+
+ /** convert DOM attributes to SAX */
+ private static Attributes saxAttributes(NamedNodeMap domAttr)
+ {
+ final String ATTR_TYPE = "CDATA";
+
+ final AttributesImpl result = new AttributesImpl();
+ for(int i=0; i < domAttr.getLength(); i++) {
+ final Attr a = (Attr)domAttr.item(i);
+ // namespace information is not provided, not needed by jfor
+ result.addAttribute(null,null,a.getName(),ATTR_TYPE,a.getValue());
+ }
+ return result;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.apache.fop.rtf.rtflib.tools;
+
+import java.io.IOException;
+import org.w3c.dom.*;
+import org.xml.sax.SAXException;
+
+/*-----------------------------------------------------------------------------
+ * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
+ *
+ * ====================================================================
+ * jfor Apache-Style Software License.
+ * Copyright (c) 2002 by the jfor project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed
+ * by the jfor project (http://www.jfor.org)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The name "jfor" must not be used to endorse
+ * or promote products derived from this software without prior written
+ * permission. For written permission, please contact info@jfor.org.
+ *
+ * 5. Products derived from this software may not be called "jfor",
+ * nor may "jfor" appear in their name, without prior written
+ * permission of info@jfor.org.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ * Contributor(s):
+-----------------------------------------------------------------------------*/
+
+/** Recursive visit of a DOM Element.
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+ */
+
+//------------------------------------------------------------------------------
+// $Id$
+// $Log$
+// Revision 1.1 2003/06/25 09:01:17 bdelacretaz
+// additional jfor packages donated to the FOP project
+//
+// Revision 1.3 2002/07/12 08:08:31 bdelacretaz
+// License changed to jfor Apache-style license
+//
+// Revision 1.2 2001/08/31 07:51:01 bdelacretaz
+// MPL license text added + javadoc class comments corrected
+//
+// Revision 1.1 2001/08/29 13:27:51 bdelacretaz
+// V0.4.1 - base package name changed to org.apache.fop.rtf.rtflib.jfor
+//
+// Revision 1.1.1.1 2001/08/02 12:53:48 bdelacretaz
+// initial SourceForge checkin of V0.1 code
+//
+//------------------------------------------------------------------------------
+
+public abstract class ElementVisitor
+{
+ /** recursively visit element e */
+ public final void visit(Element e)
+ throws IOException,SAXException
+ {
+ if(e!=null) {
+ startElement(e);
+
+ final NodeList list = e.getChildNodes();
+ for(int i=0; i < list.getLength(); i++) {
+ Node n = list.item(i);
+ if(n instanceof Element) {
+ visit((Element)n);
+ } else if(n instanceof CDATASection) {
+ visitCDATA((CDATASection)n);
+ } else if(n instanceof Text) {
+ visitText((Text)n);
+ } else if(n instanceof Comment) {
+ visitComment((Comment)n);
+ } else {
+ visitNode(n);
+ }
+ }
+
+ endElement(e);
+ }
+ }
+
+ /** called at the start of the visit of an Element */
+ protected abstract void startElement(Element e) throws IOException,SAXException;
+
+ /** called at the end of the visit of an Element */
+ protected abstract void endElement(Element e) throws IOException,SAXException;
+
+ /** called to visit a Text node */
+ protected abstract void visitText(Text t) throws IOException,SAXException;
+
+ /** called to visit a CDATASection node */
+ protected abstract void visitCDATA(CDATASection cds) throws IOException,SAXException;
+
+ /** called to visit a Comment node */
+ protected abstract void visitComment(Comment c) throws IOException,SAXException;
+
+ /** called to visit a Node that is not of the other types */
+ protected abstract void visitNode(Node n) throws IOException,SAXException;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * File: ImageConstants.java
+ *
+ *
+ * Date Author Changes
+ * Aug 16 01 Andreas Putz Created
+ * Aug 17 01 Andreas Putz Extended with "gif"
+ *
+ * (c) 2001 skynamics AG All rights reserved.
+ */
+package org.apache.fop.rtf.rtflib.tools;
+
+import java.util.Hashtable;
+
+/*-----------------------------------------------------------------------------
+ * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
+ *
+ * ====================================================================
+ * jfor Apache-Style Software License.
+ * Copyright (c) 2002 by the jfor project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed
+ * by the jfor project (http://www.jfor.org)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The name "jfor" must not be used to endorse
+ * or promote products derived from this software without prior written
+ * permission. For written permission, please contact info@jfor.org.
+ *
+ * 5. Products derived from this software may not be called "jfor",
+ * nor may "jfor" appear in their name, without prior written
+ * permission of info@jfor.org.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ * Contributor(s):
+-----------------------------------------------------------------------------*/
+
+/** Here will be defined all supported image formats.
+ * This class belongs to the <fo:external-graphic> tag processing.
+ * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
+ */
+
+public class ImageConstants
+{
+ //////////////////////////////////////////////////
+ // @@ Symbolic constants
+ //////////////////////////////////////////////////
+
+ /** Defines the case, if image is not supported */
+ public static int I_NOT_SUPPORTED = -1;
+
+ public static int I_EMF = 0;
+ public static int I_PNG = 1;
+ public static int I_JPG = 2;
+
+ /** Defines the RTF properties */
+ public static String [] RTF_TAGS = new String []
+ {
+ "emfblip", "pngblip", "jpegblip"
+ };
+
+ public static int I_TO_CONVERT_BASIS = 50;
+ public static int I_GIF = 50;
+ public static int I_JPG_C = 51;
+
+ /** Defines the types for converting rtf supported image types */
+ public static int [] CONVERT_TO = new int []
+ {
+ I_JPG, I_JPG
+ };
+
+ /** EMF file extension */
+ public static String EMF_EXT = "emf";
+ /** PNG file extension */
+ public static String PNG_EXT = "png";
+ /** JPG file extension */
+ public static String JPG_EXT = "jpg";
+ /** JPEG file extension */
+ public static String JPEG_EXT = "jpeg";
+ /** GIF file extension */
+ public static String GIF_EXT = "gif";
+
+ /** Defines the file extensions and the RTF property belongs to */
+ public static Hashtable SUPPORTED_IMAGE_TYPES = new Hashtable ();
+ static
+ {
+ SUPPORTED_IMAGE_TYPES.put (EMF_EXT, new Integer (I_EMF));
+ SUPPORTED_IMAGE_TYPES.put (PNG_EXT, new Integer (I_PNG));
+ SUPPORTED_IMAGE_TYPES.put (JPG_EXT, new Integer (I_JPG_C));
+ SUPPORTED_IMAGE_TYPES.put (JPEG_EXT,new Integer (I_JPG_C));
+ SUPPORTED_IMAGE_TYPES.put (GIF_EXT, new Integer (I_GIF));
+ }
+
+ //////////////////////////////////////////////////
+ // @@ Construction
+ //////////////////////////////////////////////////
+
+ /**
+ * Private constructor.
+ */
+ private ImageConstants()
+ {
+ }
+}
--- /dev/null
+package org.apache.fop.rtf.rtflib.tools;
+
+/*-----------------------------------------------------------------------------
+ * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
+ *
+ * ====================================================================
+ * jfor Apache-Style Software License.
+ * Copyright (c) 2002 by the jfor project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed
+ * by the jfor project (http://www.jfor.org)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The name "jfor" must not be used to endorse
+ * or promote products derived from this software without prior written
+ * permission. For written permission, please contact info@jfor.org.
+ *
+ * 5. Products derived from this software may not be called "jfor",
+ * nor may "jfor" appear in their name, without prior written
+ * permission of info@jfor.org.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ * Contributor(s):
+-----------------------------------------------------------------------------*/
+
+/** Misc.utilities for images handling
+ * This class belongs to the <fo:external-graphic> tag processing.
+ * @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
+ */
+public class ImageUtil
+{
+
+ //////////////////////////////////////////////////
+ // @@ Construction
+ //////////////////////////////////////////////////
+
+ /**
+ * Private constructor.
+ */
+ private ImageUtil ()
+ {
+ }
+
+
+ //////////////////////////////////////////////////
+ // @@ Public static methods
+ //////////////////////////////////////////////////
+
+ /**
+ * Determines the digits from a string.
+ *
+ * @param value String with digits
+ *
+ * @return
+ * -1 There is no digit\n
+ * number The digits as integer
+ */
+ public static int getInt (String value)
+ {
+ String retString = new String ();
+ StringBuffer s = new StringBuffer (value);
+ int len = s.length ();
+
+ for (int i = 0; i < len; i++)
+ {
+ if (Character.isDigit (s.charAt (i)))
+ {
+ retString += s.charAt (i);
+ }
+ }
+
+ if (retString.length () == 0)
+ {
+ return -1;
+ }
+ else
+ {
+ return Integer.parseInt (retString);
+ }
+ }
+
+ /**
+ * Checks the string for percent character at the end of string.
+ *
+ * @param value String with digits
+ *
+ * @return
+ * true The string contains a % value
+ * false Other string
+ */
+ public static boolean isPercent (String value)
+ {
+ if (value.endsWith ("%"))
+ {
+ return true;
+
+ }
+
+ return false;
+ }
+
+ /**
+ * Compares two hexadecimal values.
+ *
+ * @param pattern Target
+ * @param data Data
+ * @param searchAt Position to start compare
+ * @param searchForward Direction to compare byte arrays
+ *
+ * @return
+ * true If equal\n
+ * false If different
+ */
+ public static boolean compareHexValues (byte[] pattern, byte[] data, int searchAt,
+ boolean searchForward)
+ {
+ if (searchAt >= data.length)
+ {
+ return false;
+
+ }
+
+ int pLen = pattern.length;
+
+ if (searchForward)
+ {
+ if (pLen >= (data.length - searchAt))
+ {
+ return false;
+
+ }
+
+ for (int i = 0; i < pLen; i++)
+ {
+ if (pattern[i] != data[searchAt + i])
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ else
+ {
+ if (pLen > (searchAt + 1))
+ {
+ return false;
+
+ }
+
+ for (int i = 0; i < pLen; i++)
+ {
+ if (pattern[pLen - i - 1] != data[searchAt - i])
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+
+ /**
+ * Determines a integer value from a hexadecimal byte array.
+ *
+ * @param data Image
+ * @param start Start index to read from
+ * @param end End index until to read
+ *
+ * @return A number
+ */
+ public static int getIntFromByteArray (byte[] data, int startAt, int length,
+ boolean searchForward)
+ {
+ int bit = 8;
+ int bitMoving = length * bit;
+ int retVal = 0;
+
+ if (startAt >= data.length)
+ {
+ return retVal;
+
+ }
+
+ if (searchForward)
+ {
+ if (length >= (data.length - startAt))
+ {
+ return retVal;
+
+ }
+
+ for (int i = 0; i < length; i++)
+ {
+ bitMoving -= bit;
+ int iData = (int) data[startAt + i];
+ if (iData < 0)
+ iData += 256;
+ retVal += iData << bitMoving;
+ }
+ }
+ else
+ {
+ if (length > (startAt + 1))
+ {
+ return retVal;
+
+ }
+
+ for (int i = 0; i < length; i++)
+ {
+ bitMoving -= bit;
+ int iData = (int) data[startAt - i];
+ if (iData < 0)
+ iData += 256;
+ retVal += iData << bitMoving; }
+ }
+
+ return retVal;
+ }
+}
\ No newline at end of file