Browse Source

Undo changes of r556112

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@557035 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_95beta
Andreas L. Delmelle 17 years ago
parent
commit
1b5c727a2d

+ 6
- 8
src/java/org/apache/fop/fonts/truetype/TTFFile.java View File

package org.apache.fop.fonts.truetype; package org.apache.fop.fonts.truetype;


import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.fop.fonts.Glyphs; import org.apache.fop.fonts.Glyphs;
import org.apache.fop.util.IntMap;


/** /**
* Reads a TrueType file or a TrueType Collection. * Reads a TrueType file or a TrueType Collection.
// internal mapping of glyph indexes to unicode indexes // internal mapping of glyph indexes to unicode indexes
// used for quick mappings in this class // used for quick mappings in this class
private IntMap glyphToUnicodeMap = new IntMap();
private IntMap unicodeToGlyphMap = new IntMap();
private Map glyphToUnicodeMap = new java.util.HashMap();
private Map unicodeToGlyphMap = new java.util.HashMap();


private TTFDirTabEntry currentDirTab; private TTFDirTabEntry currentDirTab;


UnicodeMapping(int glyphIndex, int unicodeIndex) { UnicodeMapping(int glyphIndex, int unicodeIndex) {
this.unicodeIndex = unicodeIndex; this.unicodeIndex = unicodeIndex;
this.glyphIndex = glyphIndex; this.glyphIndex = glyphIndex;
glyphToUnicodeMap.put(glyphIndex, unicodeIndex);
unicodeToGlyphMap.put(unicodeIndex, glyphIndex);
glyphToUnicodeMap.put(new Integer(glyphIndex), new Integer(unicodeIndex));
unicodeToGlyphMap.put(new Integer(unicodeIndex), new Integer(glyphIndex));
} }


/** /**
* @throws IOException if glyphIndex not found * @throws IOException if glyphIndex not found
*/ */
private Integer glyphToUnicode(int glyphIndex) throws IOException { private Integer glyphToUnicode(int glyphIndex) throws IOException {
return new Integer(glyphToUnicodeMap.get(glyphIndex));
return (Integer) glyphToUnicodeMap.get(new Integer(glyphIndex));
} }
/** /**
*/ */
private Integer unicodeToGlyph(int unicodeIndex) throws IOException { private Integer unicodeToGlyph(int unicodeIndex) throws IOException {
final Integer result = final Integer result =
new Integer(unicodeToGlyphMap.get(unicodeIndex));
(Integer) unicodeToGlyphMap.get(new Integer(unicodeIndex));
if (result == null) { if (result == null) {
throw new IOException( throw new IOException(
"Glyph index not found for unicode value " + unicodeIndex); "Glyph index not found for unicode value " + unicodeIndex);

+ 4
- 4
src/java/org/apache/fop/util/CMYKColorSpace.java View File

} }


/** /**
* @see java.awt.color.ColorSpace#toRGB(float[])
* @inheritDoc java.awt.color.ColorSpace#toRGB(float[])
*/ */
public float[] toRGB(float[] colorvalue) { public float[] toRGB(float[] colorvalue) {
return new float [] { return new float [] {
} }


/** /**
* @see java.awt.color.ColorSpace#fromRGB(float[])
* @inheritDoc java.awt.color.ColorSpace#fromRGB(float[])
*/ */
public float[] fromRGB(float[] rgbvalue) { public float[] fromRGB(float[] rgbvalue) {
throw new UnsupportedOperationException("NYI"); throw new UnsupportedOperationException("NYI");
} }


/** /**
* @see java.awt.color.ColorSpace#toCIEXYZ(float[])
* @inheritDoc java.awt.color.ColorSpace#toCIEXYZ(float[])
*/ */
public float[] toCIEXYZ(float[] colorvalue) { public float[] toCIEXYZ(float[] colorvalue) {
throw new UnsupportedOperationException("NYI"); throw new UnsupportedOperationException("NYI");
} }


/** /**
* @see java.awt.color.ColorSpace#fromCIEXYZ(float[])
* @inheritDoc java.awt.color.ColorSpace#fromCIEXYZ(float[])
*/ */
public float[] fromCIEXYZ(float[] colorvalue) { public float[] fromCIEXYZ(float[] colorvalue) {
throw new UnsupportedOperationException("NYI"); throw new UnsupportedOperationException("NYI");

+ 1
- 1
src/java/org/apache/fop/util/CloseBlockerOutputStream.java View File

} }


/** /**
* @see java.io.OutputStream#close()
* @inheritDoc java.io.OutputStream#close()
*/ */
public void close() throws IOException { public void close() throws IOException {
try { try {

+ 1
- 1
src/java/org/apache/fop/util/ColorUtil.java View File

* @return a color if possible * @return a color if possible
* @throws PropertyException * @throws PropertyException
* if the format is wrong. * if the format is wrong.
* @see java.awt.Color#toString()
* @inheritDoc java.awt.Color#toString()
*/ */
private static Color parseAsJavaAWTColor(String value) private static Color parseAsJavaAWTColor(String value)
throws PropertyException { throws PropertyException {

+ 18
- 18
src/java/org/apache/fop/util/CommandLineLogger.java View File

} }
/** /**
* @see org.apache.commons.logging.Log#isTraceEnabled()
* @inheritDoc org.apache.commons.logging.Log#isTraceEnabled()
*/ */
public final boolean isTraceEnabled() { public final boolean isTraceEnabled() {
return logLevel <= LOG_LEVEL_TRACE; return logLevel <= LOG_LEVEL_TRACE;
} }


/** /**
* @see org.apache.commons.logging.Log#isDebugEnabled()
* @inheritDoc org.apache.commons.logging.Log#isDebugEnabled()
*/ */
public final boolean isDebugEnabled() { public final boolean isDebugEnabled() {
return logLevel <= LOG_LEVEL_DEBUG; return logLevel <= LOG_LEVEL_DEBUG;
} }


/** /**
* @see org.apache.commons.logging.Log#isInfoEnabled()
* @inheritDoc org.apache.commons.logging.Log#isInfoEnabled()
*/ */
public final boolean isInfoEnabled() { public final boolean isInfoEnabled() {
return logLevel <= LOG_LEVEL_INFO; return logLevel <= LOG_LEVEL_INFO;
} }
/** /**
* @see org.apache.commons.logging.Log#isWarnEnabled()
* @inheritDoc org.apache.commons.logging.Log#isWarnEnabled()
*/ */
public final boolean isWarnEnabled() { public final boolean isWarnEnabled() {
return logLevel <= LOG_LEVEL_WARN; return logLevel <= LOG_LEVEL_WARN;
} }


/** /**
* @see org.apache.commons.logging.Log#isErrorEnabled()
* @inheritDoc org.apache.commons.logging.Log#isErrorEnabled()
*/ */
public final boolean isErrorEnabled() { public final boolean isErrorEnabled() {
return logLevel <= LOG_LEVEL_ERROR; return logLevel <= LOG_LEVEL_ERROR;
} }


/** /**
* @see org.apache.commons.logging.Log#isFatalEnabled()
* @inheritDoc org.apache.commons.logging.Log#isFatalEnabled()
*/ */
public final boolean isFatalEnabled() { public final boolean isFatalEnabled() {
return logLevel <= LOG_LEVEL_FATAL; return logLevel <= LOG_LEVEL_FATAL;
} }
/** /**
* @see org.apache.commons.logging.Log#trace(java.lang.Object)
* @inheritDoc org.apache.commons.logging.Log#trace(java.lang.Object)
*/ */
public final void trace(Object message) { public final void trace(Object message) {
if (isTraceEnabled()) { if (isTraceEnabled()) {
} }


/** /**
* @see org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable)
* @inheritDoc org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable)
*/ */
public final void trace(Object message, Throwable t) { public final void trace(Object message, Throwable t) {
if (isTraceEnabled()) { if (isTraceEnabled()) {
} }


/** /**
* @see org.apache.commons.logging.Log#debug(java.lang.Object)
* @inheritDoc org.apache.commons.logging.Log#debug(java.lang.Object)
*/ */
public final void debug(Object message) { public final void debug(Object message) {
if (isDebugEnabled()) { if (isDebugEnabled()) {
} }


/** /**
* @see org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable)
* @inheritDoc org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable)
*/ */
public final void debug(Object message, Throwable t) { public final void debug(Object message, Throwable t) {
if (isDebugEnabled()) { if (isDebugEnabled()) {
} }


/** /**
* @see org.apache.commons.logging.Log#info(java.lang.Object)
* @inheritDoc org.apache.commons.logging.Log#info(java.lang.Object)
*/ */
public final void info(Object message) { public final void info(Object message) {
if (isInfoEnabled()) { if (isInfoEnabled()) {
} }


/** /**
* @see org.apache.commons.logging.Log#info(java.lang.Object, java.lang.Throwable)
* @inheritDoc org.apache.commons.logging.Log#info(java.lang.Object, java.lang.Throwable)
*/ */
public final void info(Object message, Throwable t) { public final void info(Object message, Throwable t) {
if (isInfoEnabled()) { if (isInfoEnabled()) {
} }


/** /**
* @see org.apache.commons.logging.Log#warn(java.lang.Object)
* @inheritDoc org.apache.commons.logging.Log#warn(java.lang.Object)
*/ */
public final void warn(Object message) { public final void warn(Object message) {
if (isWarnEnabled()) { if (isWarnEnabled()) {
} }


/** /**
* @see org.apache.commons.logging.Log#warn(java.lang.Object, java.lang.Throwable)
* @inheritDoc org.apache.commons.logging.Log#warn(java.lang.Object, java.lang.Throwable)
*/ */
public final void warn(Object message, Throwable t) { public final void warn(Object message, Throwable t) {
if (isWarnEnabled()) { if (isWarnEnabled()) {
} }


/** /**
* @see org.apache.commons.logging.Log#error(java.lang.Object)
* @inheritDoc org.apache.commons.logging.Log#error(java.lang.Object)
*/ */
public final void error(Object message) { public final void error(Object message) {
if (isErrorEnabled()) { if (isErrorEnabled()) {
} }


/** /**
* @see org.apache.commons.logging.Log#error(java.lang.Object, java.lang.Throwable)
* @inheritDoc org.apache.commons.logging.Log#error(java.lang.Object, java.lang.Throwable)
*/ */
public final void error(Object message, Throwable t) { public final void error(Object message, Throwable t) {
if (isErrorEnabled()) { if (isErrorEnabled()) {
} }


/** /**
* @see org.apache.commons.logging.Log#fatal(java.lang.Object)
* @inheritDoc org.apache.commons.logging.Log#fatal(java.lang.Object)
*/ */
public final void fatal(Object message) { public final void fatal(Object message) {
if (isFatalEnabled()) { if (isFatalEnabled()) {
} }


/** /**
* @see org.apache.commons.logging.Log#fatal(java.lang.Object, java.lang.Throwable)
* @inheritDoc org.apache.commons.logging.Log#fatal(java.lang.Object, java.lang.Throwable)
*/ */
public final void fatal(Object message, Throwable t) { public final void fatal(Object message, Throwable t) {
if (isFatalEnabled()) { if (isFatalEnabled()) {

+ 7
- 7
src/java/org/apache/fop/util/DOMBuilderContentHandlerFactory.java View File

this.domImplementation = domImplementation; this.domImplementation = domImplementation;
} }
/** @see org.apache.fop.util.ContentHandlerFactory#getSupportedNamespaces() */
/** @inheritDoc org.apache.fop.util.ContentHandlerFactory#getSupportedNamespaces() */
public String[] getSupportedNamespaces() { public String[] getSupportedNamespaces() {
return new String[] {namespaceURI}; return new String[] {namespaceURI};
} }


/** @see org.apache.fop.util.ContentHandlerFactory#createContentHandler() */
/** @inheritDoc org.apache.fop.util.ContentHandlerFactory#createContentHandler() */
public ContentHandler createContentHandler() throws SAXException { public ContentHandler createContentHandler() throws SAXException {
return new Handler(); return new Handler();
} }
} }
/** /**
* @see org.apache.fop.util.ContentHandlerFactory.ObjectSource#getObject()
* @inheritDoc org.apache.fop.util.ContentHandlerFactory.ObjectSource#getObject()
*/ */
public Object getObject() { public Object getObject() {
return getDocument(); return getDocument();
} }


/** /**
* @see org.apache.fop.util.ContentHandlerFactory.ObjectSource
* @inheritDoc org.apache.fop.util.ContentHandlerFactory.ObjectSource
*/ */
public void setObjectBuiltListener(ObjectBuiltListener listener) { public void setObjectBuiltListener(ObjectBuiltListener listener) {
this.obListener = listener; this.obListener = listener;
} }
/** /**
* @see org.apache.fop.util.DelegatingContentHandler#startDocument()
* @inheritDoc org.apache.fop.util.DelegatingContentHandler#startDocument()
*/ */
public void startDocument() throws SAXException { public void startDocument() throws SAXException {
//Suppress startDocument() call if doc has not been set, yet. It will be done later. //Suppress startDocument() call if doc has not been set, yet. It will be done later.
} }


/** /**
* @see org.apache.fop.util.DelegatingContentHandler
* @inheritDoc org.apache.fop.util.DelegatingContentHandler
*/ */
public void startElement(String uri, String localName, String qName, Attributes atts) public void startElement(String uri, String localName, String qName, Attributes atts)
throws SAXException { throws SAXException {
} }


/** /**
* @see org.apache.fop.util.DelegatingContentHandler#endDocument()
* @inheritDoc org.apache.fop.util.DelegatingContentHandler#endDocument()
*/ */
public void endDocument() throws SAXException { public void endDocument() throws SAXException {
super.endDocument(); super.endDocument();

+ 2
- 2
src/java/org/apache/fop/util/DataURIResolver.java View File

public class DataURIResolver implements URIResolver { public class DataURIResolver implements URIResolver {


/** /**
* @see javax.xml.transform.URIResolver#resolve(java.lang.String, java.lang.String)
* @inheritDoc javax.xml.transform.URIResolver#resolve(java.lang.String, java.lang.String)
*/ */
public Source resolve(String href, String base) throws TransformerException { public Source resolve(String href, String base) throws TransformerException {
if (href.startsWith("data:")) { if (href.startsWith("data:")) {
* Parses inline data URIs as generated by MS Word's XML export and FO * Parses inline data URIs as generated by MS Word's XML export and FO
* stylesheet. * stylesheet.
* *
* @see <a href="http://www.ietf.org/rfc/rfc2397">RFC 2397</a>
* @inheritDoc <a href="http://www.ietf.org/rfc/rfc2397">RFC 2397</a>
*/ */
private Source parseDataURI(String href) { private Source parseDataURI(String href) {
int commaPos = href.indexOf(','); int commaPos = href.indexOf(',');

+ 3
- 3
src/java/org/apache/fop/util/DefaultErrorListener.java View File

} }
/** /**
* @see javax.xml.transform.ErrorListener#warning(javax.xml.transform.TransformerException)
* @inheritDoc javax.xml.transform.ErrorListener#warning(javax.xml.transform.TransformerException)
*/ */
public void warning(TransformerException exc) { public void warning(TransformerException exc) {
log.warn(exc.toString()); log.warn(exc.toString());
} }


/** /**
* @see javax.xml.transform.ErrorListener#error(javax.xml.transform.TransformerException)
* @inheritDoc javax.xml.transform.ErrorListener#error(javax.xml.transform.TransformerException)
*/ */
public void error(TransformerException exc) throws TransformerException { public void error(TransformerException exc) throws TransformerException {
throw exc; throw exc;
} }


/** /**
* @see javax.xml.transform.ErrorListener#fatalError(javax.xml.transform.TransformerException)
* @inheritDoc javax.xml.transform.ErrorListener#fatalError(javax.xml.transform.TransformerException)
*/ */
public void fatalError(TransformerException exc) public void fatalError(TransformerException exc)
throws TransformerException { throws TransformerException {

+ 24
- 24
src/java/org/apache/fop/util/DelegatingContentHandler.java View File

// ==== EntityResolver // ==== EntityResolver
/** /**
* @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
* @inheritDoc org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
*/ */
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
if (entityResolver != null) { if (entityResolver != null) {
// ==== DTDHandler // ==== DTDHandler


/** /**
* @see org.xml.sax.DTDHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String)
* @inheritDoc org.xml.sax.DTDHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String)
*/ */
public void notationDecl(String name, String publicId, String systemId) throws SAXException { public void notationDecl(String name, String publicId, String systemId) throws SAXException {
if (dtdHandler != null) { if (dtdHandler != null) {
} }


/** /**
* @see org.xml.sax.DTDHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
* @inheritDoc org.xml.sax.DTDHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/ */
public void unparsedEntityDecl(String name, String publicId, String systemId, public void unparsedEntityDecl(String name, String publicId, String systemId,
String notationName) throws SAXException { String notationName) throws SAXException {
// ==== ContentHandler // ==== ContentHandler
/** /**
* @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
* @inheritDoc org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
*/ */
public void setDocumentLocator(Locator locator) { public void setDocumentLocator(Locator locator) {
delegate.setDocumentLocator(locator); delegate.setDocumentLocator(locator);
} }


/** /**
* @see org.xml.sax.ContentHandler#startDocument()
* @inheritDoc org.xml.sax.ContentHandler#startDocument()
*/ */
public void startDocument() throws SAXException { public void startDocument() throws SAXException {
delegate.startDocument(); delegate.startDocument();
} }


/** /**
* @see org.xml.sax.ContentHandler#endDocument()
* @inheritDoc org.xml.sax.ContentHandler#endDocument()
*/ */
public void endDocument() throws SAXException { public void endDocument() throws SAXException {
delegate.endDocument(); delegate.endDocument();
} }


/** /**
* @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
* @inheritDoc org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
*/ */
public void startPrefixMapping(String prefix, String uri) throws SAXException { public void startPrefixMapping(String prefix, String uri) throws SAXException {
delegate.startPrefixMapping(prefix, uri); delegate.startPrefixMapping(prefix, uri);
} }


/** /**
* @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
* @inheritDoc org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
*/ */
public void endPrefixMapping(String prefix) throws SAXException { public void endPrefixMapping(String prefix) throws SAXException {
delegate.endPrefixMapping(prefix); delegate.endPrefixMapping(prefix);
} }


/** /**
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
* @inheritDoc org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
*/ */
public void startElement(String uri, String localName, String qName, public void startElement(String uri, String localName, String qName,
Attributes atts) throws SAXException { Attributes atts) throws SAXException {
} }


/** /**
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
* @inheritDoc org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
*/ */
public void endElement(String uri, String localName, String qName) throws SAXException { public void endElement(String uri, String localName, String qName) throws SAXException {
delegate.endElement(uri, localName, qName); delegate.endElement(uri, localName, qName);
} }


/** /**
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
* @inheritDoc org.xml.sax.ContentHandler#characters(char[], int, int)
*/ */
public void characters(char[] ch, int start, int length) throws SAXException { public void characters(char[] ch, int start, int length) throws SAXException {
delegate.characters(ch, start, length); delegate.characters(ch, start, length);
} }


/** /**
* @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
* @inheritDoc org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
*/ */
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
delegate.ignorableWhitespace(ch, start, length); delegate.ignorableWhitespace(ch, start, length);
} }


/** /**
* @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
* @inheritDoc org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
*/ */
public void processingInstruction(String target, String data) throws SAXException { public void processingInstruction(String target, String data) throws SAXException {
delegate.processingInstruction(target, data); delegate.processingInstruction(target, data);
} }


/** /**
* @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
* @inheritDoc org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
*/ */
public void skippedEntity(String name) throws SAXException { public void skippedEntity(String name) throws SAXException {
delegate.skippedEntity(name); delegate.skippedEntity(name);
// ==== LexicalHandler // ==== LexicalHandler
/** /**
* @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
* @inheritDoc org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
*/ */
public void startDTD(String name, String publicId, String systemId) throws SAXException { public void startDTD(String name, String publicId, String systemId) throws SAXException {
if (lexicalHandler != null) { if (lexicalHandler != null) {
} }


/** /**
* @see org.xml.sax.ext.LexicalHandler#endDTD()
* @inheritDoc org.xml.sax.ext.LexicalHandler#endDTD()
*/ */
public void endDTD() throws SAXException { public void endDTD() throws SAXException {
if (lexicalHandler != null) { if (lexicalHandler != null) {
} }


/** /**
* @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
* @inheritDoc org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
*/ */
public void startEntity(String name) throws SAXException { public void startEntity(String name) throws SAXException {
if (lexicalHandler != null) { if (lexicalHandler != null) {
} }


/** /**
* @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
* @inheritDoc org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
*/ */
public void endEntity(String name) throws SAXException { public void endEntity(String name) throws SAXException {
if (lexicalHandler != null) { if (lexicalHandler != null) {
} }


/** /**
* @see org.xml.sax.ext.LexicalHandler#startCDATA()
* @inheritDoc org.xml.sax.ext.LexicalHandler#startCDATA()
*/ */
public void startCDATA() throws SAXException { public void startCDATA() throws SAXException {
if (lexicalHandler != null) { if (lexicalHandler != null) {
} }


/** /**
* @see org.xml.sax.ext.LexicalHandler#endCDATA()
* @inheritDoc org.xml.sax.ext.LexicalHandler#endCDATA()
*/ */
public void endCDATA() throws SAXException { public void endCDATA() throws SAXException {
if (lexicalHandler != null) { if (lexicalHandler != null) {
} }


/** /**
* @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
* @inheritDoc org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
*/ */
public void comment(char[] ch, int start, int length) throws SAXException { public void comment(char[] ch, int start, int length) throws SAXException {
if (lexicalHandler != null) { if (lexicalHandler != null) {
// ==== ErrorHandler // ==== ErrorHandler


/** /**
* @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
* @inheritDoc org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
*/ */
public void warning(SAXParseException exception) throws SAXException { public void warning(SAXParseException exception) throws SAXException {
if (errorHandler != null) { if (errorHandler != null) {
} }


/** /**
* @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
* @inheritDoc org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
*/ */
public void error(SAXParseException exception) throws SAXException { public void error(SAXParseException exception) throws SAXException {
if (errorHandler != null) { if (errorHandler != null) {
} }


/** /**
* @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
* @inheritDoc org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
*/ */
public void fatalError(SAXParseException exception) throws SAXException { public void fatalError(SAXParseException exception) throws SAXException {
if (errorHandler != null) { if (errorHandler != null) {

+ 0
- 248
src/java/org/apache/fop/util/IntMap.java View File

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package org.apache.fop.util;

/**
* Dedicated map for storing int-to-int mappings,
* where the key is always a positive <code>int</code>.
*
*/
public class IntMap {

private static final int DEFAULT_CAPACITY = 256;
private int[] cachedKeys;
private int[] cachedValues;
private Entry[] entries;
private int initialCapacity = DEFAULT_CAPACITY;
private int currentSize;
/**
* Creates an IntMap instance with an <code>initialCapacity</code>
* of 256 mappings
*
*/
public IntMap() {
this(DEFAULT_CAPACITY);
}
/**
* Creates an IntMap instance with the supplied
* <code>initialCapacity</code>
*
* @param initialCapacity the map's initial capacity
*/
public IntMap(int initialCapacity) {
this.initialCapacity = initialCapacity;
initMap();
}
private void initMap() {
this.entries = new Entry[initialCapacity];
this.currentSize = 0;
}
/**
* Clears the map, and re-initializes it
*/
public void clear() {
initMap();
}

/**
* Checks whether a mapping for the specified key exists.
* @param key the key to look up
* @return true if the map contains a mapping for the specified key
*/
public boolean containsKey(int key) {
return (key >= 0)
&& (currentSize > 0)
&& (searchKeyIndex(key) == key);
}
/**
*
* @param key the key
* @return the corresponding value; a value of 0 can
* either mean that the key is mapped to 0
* or that the key is not mapped at all; use
* <code>containsKey(int)</code> to find
* out if a mapping exists
*/
public int get(int key) {
if (key >= 0 && currentSize > 0) {
int idx = searchKeyIndex(key);
if (entries[idx] != null) {
return entries[idx].mapping[1];
} else {
return 0;
}
} else {
return 0;
}
}
/**
* Adds a mapping corresponding to the key-value pair
* @param key the key for which to create the mapping
* @param value the mapped value
* @return the value that was previously associated with the
* specified key; a value of 0 can mean either that
* the key was unmapped or mapped to the value 0
*/
public int put(int key, int value) {
if (key >= 0) {
ensureCapacity(key + 1);
int keyIndex = searchKeyIndex(key);
int retVal = 0;;
if (entries[keyIndex] == null) {
entries[currentSize++] = new Entry(key, value);
cachedKeys = null;;
} else {
retVal = entries[keyIndex].mapping[1];
entries[keyIndex].mapping[1] = value;
}
cachedValues = null;
return retVal;
} else {
throw new IllegalArgumentException(
"This map allows only positive integers as keys.");
}
}

/**
* Removes the mapping corresponding to the key
* @param key the key of the mapping to be removed
* @return the value that was associated with the given key;
* a value of 0 can mean that the key was either
* unmapped or mapped to the value 0
*/
public int remove(int key) {
if (key >= 0
&& currentSize > 0) {
int keyIndex = searchKeyIndex(key);
int retVal = 0;
if (entries[keyIndex] != null
&& entries[keyIndex].mapping[0] == key) {
retVal = entries[key].mapping[0];
entries[key] = null;
cachedKeys = null;
cachedValues = null;
currentSize--;
}
return retVal;
} else {
return 0;
}
}
/**
* Get an array containing the mapped keys
* @return the keys as an array of <code>int</code>
*/
public int[] keys() {
if (currentSize > 0
&& cachedKeys == null) {
cachedKeys = new int[currentSize];
int keyIndex = currentSize;
for (int i = entries.length; --i >= 0;) {
if (entries[i] != null) {
cachedKeys[--keyIndex] = entries[i].mapping[0];
}
}
}
return cachedKeys;
}
/**
* Get an array containing the mapped values
* @return the values as an array of <code>int</code>
*/
public int[] values() {
if (currentSize > 0
&& cachedValues == null) {
cachedValues = new int[currentSize];
int valIndex = currentSize;
for (int i = entries.length; --i >= 0;) {
if (entries[i] != null) {
cachedValues[--valIndex] = entries[i].mapping[0];
}
}
}
return cachedValues;
}

/**
* Get the size of the map (= the number of keys that are mapped)
* @return the size of the map
*/
public int size() {
return currentSize;
}
private void ensureCapacity(int minCapacity) {
if (entries.length == 0) {
entries = new Entry[minCapacity];
} else if (entries.length < minCapacity) {
int newCap = entries.length + 1;
while (newCap < minCapacity) {
newCap += (newCap / 2);
}
Entry[] oldEntries = entries;
entries = new Entry[newCap];
System.arraycopy(oldEntries, 0, entries, 0, oldEntries.length);
}
}
private final int searchKeyIndex(int key) {
if (currentSize > 0) {
int start = 0;
int end = currentSize;
int mid;
while (end >= start) {
mid = (start + end) / 2;
if (entries[mid] == null || entries[mid].mapping[0] > key) {
end = mid - 1;
} else if (entries[mid].mapping[0] == key) {
return mid;
} else {
start = mid + 1;
}
}
return start;
} else {
return 0;
}
}
private static final class Entry {
protected int[] mapping;
private Entry(int key, int value) {
this.mapping = new int[]{key, value};
}
}
}

+ 3
- 3
src/java/org/apache/fop/util/QName.java View File

return getPrefix() != null ? getPrefix() + ':' + getLocalName() : getLocalName(); return getPrefix() != null ? getPrefix() + ':' + getLocalName() : getLocalName();
} }
/** @see java.lang.Object#hashCode() */
/** @inheritDoc java.lang.Object#hashCode() */
public int hashCode() { public int hashCode() {
return this.hashCode; return this.hashCode;
} }
/** @see java.lang.Object#equals(java.lang.Object) */
/** @inheritDoc java.lang.Object#equals(java.lang.Object) */
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
return false; return false;
return false; return false;
} }
/** @see java.lang.Object#toString() */
/** @inheritDoc java.lang.Object#toString() */
public String toString() { public String toString() {
return prefix != null return prefix != null
? (prefix + ":" + localName) ? (prefix + ":" + localName)

+ 5
- 5
src/java/org/apache/fop/util/WriterOutputStream.java View File

} }


/** /**
* @see java.io.OutputStream#close()
* @inheritDoc java.io.OutputStream#close()
*/ */
public void close() throws IOException { public void close() throws IOException {
writer.close(); writer.close();
} }


/** /**
* @see java.io.OutputStream#flush()
* @inheritDoc java.io.OutputStream#flush()
*/ */
public void flush() throws IOException { public void flush() throws IOException {
writer.flush(); writer.flush();
} }


/** /**
* @see java.io.OutputStream#write(byte[], int, int)
* @inheritDoc java.io.OutputStream#write(byte[], int, int)
*/ */
public void write(byte[] buf, int offset, int length) throws IOException { public void write(byte[] buf, int offset, int length) throws IOException {
if (encoding != null) { if (encoding != null) {
} }


/** /**
* @see java.io.OutputStream#write(byte[])
* @inheritDoc java.io.OutputStream#write(byte[])
*/ */
public void write(byte[] buf) throws IOException { public void write(byte[] buf) throws IOException {
write(buf, 0, buf.length); write(buf, 0, buf.length);
} }


/** /**
* @see java.io.OutputStream#write(int)
* @inheritDoc java.io.OutputStream#write(int)
*/ */
public void write(int b) throws IOException { public void write(int b) throws IOException {
write(new byte[] {(byte)b}); write(new byte[] {(byte)b});

Loading…
Cancel
Save