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

@@ -20,7 +20,6 @@
package org.apache.fop.fonts.truetype;

import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.List;
@@ -28,7 +27,6 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.fonts.Glyphs;
import org.apache.fop.util.IntMap;

/**
* Reads a TrueType file or a TrueType Collection.
@@ -111,8 +109,8 @@ public class TTFFile {
// internal mapping of glyph indexes to unicode indexes
// 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;

@@ -134,8 +132,8 @@ public class TTFFile {
UnicodeMapping(int glyphIndex, int unicodeIndex) {
this.unicodeIndex = unicodeIndex;
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));
}

/**
@@ -1505,7 +1503,7 @@ public class TTFFile {
* @throws IOException if glyphIndex not found
*/
private Integer glyphToUnicode(int glyphIndex) throws IOException {
return new Integer(glyphToUnicodeMap.get(glyphIndex));
return (Integer) glyphToUnicodeMap.get(new Integer(glyphIndex));
}
/**
@@ -1517,7 +1515,7 @@ public class TTFFile {
*/
private Integer unicodeToGlyph(int unicodeIndex) throws IOException {
final Integer result =
new Integer(unicodeToGlyphMap.get(unicodeIndex));
(Integer) unicodeToGlyphMap.get(new Integer(unicodeIndex));
if (result == null) {
throw new IOException(
"Glyph index not found for unicode value " + unicodeIndex);

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

@@ -48,7 +48,7 @@ public class CMYKColorSpace extends ColorSpace {
}

/**
* @see java.awt.color.ColorSpace#toRGB(float[])
* @inheritDoc java.awt.color.ColorSpace#toRGB(float[])
*/
public float[] toRGB(float[] colorvalue) {
return new float [] {
@@ -58,21 +58,21 @@ public class CMYKColorSpace extends ColorSpace {
}

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

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

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

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

@@ -36,7 +36,7 @@ public class CloseBlockerOutputStream extends FilterOutputStream {
}

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

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

@@ -157,7 +157,7 @@ public final class ColorUtil {
* @return a color if possible
* @throws PropertyException
* if the format is wrong.
* @see java.awt.Color#toString()
* @inheritDoc java.awt.Color#toString()
*/
private static Color parseAsJavaAWTColor(String value)
throws PropertyException {

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

@@ -74,49 +74,49 @@ public class CommandLineLogger implements Log {
}
/**
* @see org.apache.commons.logging.Log#isTraceEnabled()
* @inheritDoc org.apache.commons.logging.Log#isTraceEnabled()
*/
public final boolean isTraceEnabled() {
return logLevel <= LOG_LEVEL_TRACE;
}

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

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

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

/**
* @see org.apache.commons.logging.Log#isFatalEnabled()
* @inheritDoc org.apache.commons.logging.Log#isFatalEnabled()
*/
public final boolean isFatalEnabled() {
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) {
if (isTraceEnabled()) {
@@ -125,7 +125,7 @@ public class CommandLineLogger implements Log {
}

/**
* @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) {
if (isTraceEnabled()) {
@@ -134,7 +134,7 @@ public class CommandLineLogger implements Log {
}

/**
* @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) {
if (isDebugEnabled()) {
@@ -143,7 +143,7 @@ public class CommandLineLogger implements Log {
}

/**
* @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) {
if (isDebugEnabled()) {
@@ -152,7 +152,7 @@ public class CommandLineLogger implements Log {
}

/**
* @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) {
if (isInfoEnabled()) {
@@ -161,7 +161,7 @@ public class CommandLineLogger implements Log {
}

/**
* @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) {
if (isInfoEnabled()) {
@@ -170,7 +170,7 @@ public class CommandLineLogger implements Log {
}

/**
* @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) {
if (isWarnEnabled()) {
@@ -179,7 +179,7 @@ public class CommandLineLogger implements Log {
}

/**
* @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) {
if (isWarnEnabled()) {
@@ -188,7 +188,7 @@ public class CommandLineLogger implements Log {
}

/**
* @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) {
if (isErrorEnabled()) {
@@ -197,7 +197,7 @@ public class CommandLineLogger implements Log {
}

/**
* @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) {
if (isErrorEnabled()) {
@@ -206,7 +206,7 @@ public class CommandLineLogger implements Log {
}

/**
* @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) {
if (isFatalEnabled()) {
@@ -215,7 +215,7 @@ public class CommandLineLogger implements Log {
}

/**
* @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) {
if (isFatalEnabled()) {

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

@@ -52,12 +52,12 @@ public class DOMBuilderContentHandlerFactory implements ContentHandlerFactory {
this.domImplementation = domImplementation;
}
/** @see org.apache.fop.util.ContentHandlerFactory#getSupportedNamespaces() */
/** @inheritDoc org.apache.fop.util.ContentHandlerFactory#getSupportedNamespaces() */
public String[] getSupportedNamespaces() {
return new String[] {namespaceURI};
}

/** @see org.apache.fop.util.ContentHandlerFactory#createContentHandler() */
/** @inheritDoc org.apache.fop.util.ContentHandlerFactory#createContentHandler() */
public ContentHandler createContentHandler() throws SAXException {
return new Handler();
}
@@ -77,21 +77,21 @@ public class DOMBuilderContentHandlerFactory implements ContentHandlerFactory {
}
/**
* @see org.apache.fop.util.ContentHandlerFactory.ObjectSource#getObject()
* @inheritDoc org.apache.fop.util.ContentHandlerFactory.ObjectSource#getObject()
*/
public Object getObject() {
return getDocument();
}

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

/**
* @see org.apache.fop.util.DelegatingContentHandler
* @inheritDoc org.apache.fop.util.DelegatingContentHandler
*/
public void startElement(String uri, String localName, String qName, Attributes atts)
throws SAXException {
@@ -125,7 +125,7 @@ public class DOMBuilderContentHandlerFactory implements ContentHandlerFactory {
}

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

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

@@ -38,7 +38,7 @@ import org.apache.xmlgraphics.util.io.Base64DecodeStream;
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 {
if (href.startsWith("data:")) {
@@ -52,7 +52,7 @@ public class DataURIResolver implements URIResolver {
* Parses inline data URIs as generated by MS Word's XML export and FO
* 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) {
int commaPos = href.indexOf(',');

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

@@ -41,21 +41,21 @@ public class DefaultErrorListener implements ErrorListener {
}
/**
* @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) {
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 {
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)
throws TransformerException {

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

@@ -106,7 +106,7 @@ public class DelegatingContentHandler
// ==== 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 {
if (entityResolver != null) {
@@ -119,7 +119,7 @@ public class DelegatingContentHandler
// ==== 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 {
if (dtdHandler != null) {
@@ -128,7 +128,7 @@ public class DelegatingContentHandler
}

/**
* @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,
String notationName) throws SAXException {
@@ -140,42 +140,42 @@ public class DelegatingContentHandler
// ==== 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) {
delegate.setDocumentLocator(locator);
}

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

/**
* @see org.xml.sax.ContentHandler#endDocument()
* @inheritDoc org.xml.sax.ContentHandler#endDocument()
*/
public void endDocument() throws SAXException {
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 {
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 {
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,
Attributes atts) throws SAXException {
@@ -183,35 +183,35 @@ public class DelegatingContentHandler
}

/**
* @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 {
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 {
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 {
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 {
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 {
delegate.skippedEntity(name);
@@ -220,7 +220,7 @@ public class DelegatingContentHandler
// ==== 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 {
if (lexicalHandler != null) {
@@ -230,7 +230,7 @@ public class DelegatingContentHandler
}

/**
* @see org.xml.sax.ext.LexicalHandler#endDTD()
* @inheritDoc org.xml.sax.ext.LexicalHandler#endDTD()
*/
public void endDTD() throws SAXException {
if (lexicalHandler != null) {
@@ -239,7 +239,7 @@ public class DelegatingContentHandler
}

/**
* @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 {
if (lexicalHandler != null) {
@@ -248,7 +248,7 @@ public class DelegatingContentHandler
}

/**
* @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 {
if (lexicalHandler != null) {
@@ -257,7 +257,7 @@ public class DelegatingContentHandler
}

/**
* @see org.xml.sax.ext.LexicalHandler#startCDATA()
* @inheritDoc org.xml.sax.ext.LexicalHandler#startCDATA()
*/
public void startCDATA() throws SAXException {
if (lexicalHandler != null) {
@@ -266,7 +266,7 @@ public class DelegatingContentHandler
}

/**
* @see org.xml.sax.ext.LexicalHandler#endCDATA()
* @inheritDoc org.xml.sax.ext.LexicalHandler#endCDATA()
*/
public void endCDATA() throws SAXException {
if (lexicalHandler != null) {
@@ -275,7 +275,7 @@ public class DelegatingContentHandler
}

/**
* @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 {
if (lexicalHandler != null) {
@@ -286,7 +286,7 @@ public class DelegatingContentHandler
// ==== 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 {
if (errorHandler != null) {
@@ -295,7 +295,7 @@ public class DelegatingContentHandler
}

/**
* @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 {
if (errorHandler != null) {
@@ -304,7 +304,7 @@ public class DelegatingContentHandler
}

/**
* @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 {
if (errorHandler != null) {

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

@@ -1,248 +0,0 @@
/*
* 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

@@ -99,12 +99,12 @@ public class QName implements Serializable {
return getPrefix() != null ? getPrefix() + ':' + getLocalName() : getLocalName();
}
/** @see java.lang.Object#hashCode() */
/** @inheritDoc java.lang.Object#hashCode() */
public int 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) {
if (obj == null) {
return false;
@@ -122,7 +122,7 @@ public class QName implements Serializable {
return false;
}
/** @see java.lang.Object#toString() */
/** @inheritDoc java.lang.Object#toString() */
public String toString() {
return prefix != null
? (prefix + ":" + localName)

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

@@ -50,21 +50,21 @@ public class WriterOutputStream extends OutputStream {
}

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

/**
* @see java.io.OutputStream#flush()
* @inheritDoc java.io.OutputStream#flush()
*/
public void flush() throws IOException {
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 {
if (encoding != null) {
@@ -75,14 +75,14 @@ public class WriterOutputStream extends OutputStream {
}

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

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

Loading…
Cancel
Save