diff options
author | Jeremias Maerki <jeremias@apache.org> | 2003-03-06 22:19:16 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2003-03-06 22:19:16 +0000 |
commit | 8a587de671d0ab6fac22e096ccaae29cd37edf46 (patch) | |
tree | 0a7cf1fbddbcb1b4d30b7caf3bac51c8dbc2a39f /src/org/apache/fop | |
parent | d708e7de1f09f12f02ab31c708c71d0310fccd2c (diff) | |
download | xmlgraphics-fop-8a587de671d0ab6fac22e096ccaae29cd37edf46.tar.gz xmlgraphics-fop-8a587de671d0ab6fac22e096ccaae29cd37edf46.zip |
Switched to long licence
Some general checkstyle fixing
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196031 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop')
24 files changed, 1380 insertions, 284 deletions
diff --git a/src/org/apache/fop/layout/AbsolutePositionProps.java b/src/org/apache/fop/layout/AbsolutePositionProps.java index d28c66345..dc937fcb1 100644 --- a/src/org/apache/fop/layout/AbsolutePositionProps.java +++ b/src/org/apache/fop/layout/AbsolutePositionProps.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; /** @@ -18,6 +61,7 @@ public class AbsolutePositionProps { public int bottom; public int left; - public AbsolutePositionProps() {} + public AbsolutePositionProps() { + } } diff --git a/src/org/apache/fop/layout/AccessibilityProps.java b/src/org/apache/fop/layout/AccessibilityProps.java index a7bd4dd5f..eed19cf0a 100644 --- a/src/org/apache/fop/layout/AccessibilityProps.java +++ b/src/org/apache/fop/layout/AccessibilityProps.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; /** @@ -15,6 +58,7 @@ public class AccessibilityProps { public String sourceDoc = null; public String role = null; - public AccessibilityProps() {} + public AccessibilityProps() { + } } diff --git a/src/org/apache/fop/layout/AreaClass.java b/src/org/apache/fop/layout/AreaClass.java index 479b7f202..fd7e3db05 100644 --- a/src/org/apache/fop/layout/AreaClass.java +++ b/src/org/apache/fop/layout/AreaClass.java @@ -1,14 +1,61 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; import org.apache.fop.apps.FOPException; +/** + * This class defines area classes. + * @todo Would better be replaced by an Enum (Avalon or Commons) + */ public class AreaClass { public static final String UNASSIGNED = "unassigned"; @@ -20,13 +67,15 @@ public class AreaClass { // checker method public static String setAreaClass(String areaClass) throws FOPException { - if (areaClass.equals(XSL_NORMAL) || areaClass.equals(XSL_ABSOLUTE) + if (areaClass.equals(XSL_NORMAL) + || areaClass.equals(XSL_ABSOLUTE) || areaClass.equals(XSL_FOOTNOTE) || areaClass.equals(XSL_SIDE_FLOAT) - || areaClass.equals(XSL_BEFORE_FLOAT)) + || areaClass.equals(XSL_BEFORE_FLOAT)) { return areaClass; - else + } else { throw new FOPException("Unknown area class '" + areaClass + "'"); + } } } diff --git a/src/org/apache/fop/layout/AuralProps.java b/src/org/apache/fop/layout/AuralProps.java index 4daf89ab4..a0eeaa6fb 100644 --- a/src/org/apache/fop/layout/AuralProps.java +++ b/src/org/apache/fop/layout/AuralProps.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; /** @@ -12,6 +55,7 @@ package org.apache.fop.layout; * Public "structure" allows direct member access. */ public class AuralProps { + public int azimuth; public String cueAfter; public String cueBefore; @@ -31,6 +75,4 @@ public class AuralProps { public int voiceFamily; public int volume; - public AuralProps() {} - } diff --git a/src/org/apache/fop/layout/BackgroundProps.java b/src/org/apache/fop/layout/BackgroundProps.java index 1e00284f3..37d1458ab 100644 --- a/src/org/apache/fop/layout/BackgroundProps.java +++ b/src/org/apache/fop/layout/BackgroundProps.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; import org.apache.fop.datatypes.Length; @@ -15,6 +58,7 @@ import org.apache.fop.datatypes.ColorType; * Public "structure" allows direct member access. */ public class BackgroundProps { + public int backAttachment; public ColorType backColor; public String backImage; @@ -22,6 +66,4 @@ public class BackgroundProps { public Length backPosHorizontal; public Length backPosVertical; - public BackgroundProps() {} - } diff --git a/src/org/apache/fop/layout/BorderAndPadding.java b/src/org/apache/fop/layout/BorderAndPadding.java index 09fc1467f..b3b46d83a 100644 --- a/src/org/apache/fop/layout/BorderAndPadding.java +++ b/src/org/apache/fop/layout/BorderAndPadding.java @@ -84,7 +84,7 @@ public class BorderAndPadding implements Cloneable { /** * Return a full copy of the BorderAndPadding information. This clones all * padding and border information. - * @return The copy. + * @see java.lang.Object#clone() */ public Object clone() throws CloneNotSupportedException { BorderAndPadding bp = (BorderAndPadding) super.clone(); @@ -123,9 +123,6 @@ public class BorderAndPadding implements Cloneable { private BorderInfo[] borderInfo = new BorderInfo[4]; private ResolvedCondLength[] padding = new ResolvedCondLength[4]; - public BorderAndPadding() { - } - public void setBorder(int side, int style, CondLength width, ColorType color) { borderInfo[side] = new BorderInfo(style, width, color); diff --git a/src/org/apache/fop/layout/FontInfo.java b/src/org/apache/fop/layout/FontInfo.java index 92872d4a9..bbd1e80a1 100644 --- a/src/org/apache/fop/layout/FontInfo.java +++ b/src/org/apache/fop/layout/FontInfo.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; // Java diff --git a/src/org/apache/fop/layout/FontState.java b/src/org/apache/fop/layout/FontState.java index 37e7b1dd0..3ebf9045d 100644 --- a/src/org/apache/fop/layout/FontState.java +++ b/src/org/apache/fop/layout/FontState.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; import java.util.Map; diff --git a/src/org/apache/fop/layout/HyphenationProps.java b/src/org/apache/fop/layout/HyphenationProps.java index c241feb72..71d18ddfa 100644 --- a/src/org/apache/fop/layout/HyphenationProps.java +++ b/src/org/apache/fop/layout/HyphenationProps.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; /** @@ -12,6 +55,7 @@ package org.apache.fop.layout; * Public "structure" allows direct member access. */ public class HyphenationProps { + public int hyphenate; // Enum true or false: store as boolean! public char hyphenationChar; public int hyphenationPushCharacterCount; @@ -19,6 +63,4 @@ public class HyphenationProps { public String language; // Language code or enum "NONE" public String country; // Country code or enum "NONE" - public HyphenationProps() {} - } diff --git a/src/org/apache/fop/layout/MarginInlineProps.java b/src/org/apache/fop/layout/MarginInlineProps.java index 495acc1f2..83b8d053f 100644 --- a/src/org/apache/fop/layout/MarginInlineProps.java +++ b/src/org/apache/fop/layout/MarginInlineProps.java @@ -1,18 +1,61 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; - /** * Store all inline "margin" related properties * Public "structure" allows direct member access. */ public class MarginInlineProps { + public int marginTop; public int marginBottom; public int marginLeft; @@ -20,6 +63,4 @@ public class MarginInlineProps { public int spaceStart; public int spaceEnd; - public MarginInlineProps() {} - } diff --git a/src/org/apache/fop/layout/MarginProps.java b/src/org/apache/fop/layout/MarginProps.java index 793fb8acf..ace7ee9b4 100644 --- a/src/org/apache/fop/layout/MarginProps.java +++ b/src/org/apache/fop/layout/MarginProps.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; /** @@ -12,6 +55,7 @@ package org.apache.fop.layout; * Public "structure" allows direct member access. */ public class MarginProps { + public int marginTop; public int marginBottom; public int marginLeft; @@ -21,6 +65,4 @@ public class MarginProps { public int startIndent; public int endIndent; - public MarginProps() {} - } diff --git a/src/org/apache/fop/layout/PageMaster.java b/src/org/apache/fop/layout/PageMaster.java index 7b98bde6b..25e32d9da 100644 --- a/src/org/apache/fop/layout/PageMaster.java +++ b/src/org/apache/fop/layout/PageMaster.java @@ -1,17 +1,60 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; import org.apache.fop.area.PageViewport; public class PageMaster { - private PageViewport pageVP ; + private PageViewport pageVP; public PageMaster(PageViewport pageVP) { this.pageVP = pageVP; diff --git a/src/org/apache/fop/layout/RelativePositionProps.java b/src/org/apache/fop/layout/RelativePositionProps.java index 4b0f2c1a5..057e05a49 100644 --- a/src/org/apache/fop/layout/RelativePositionProps.java +++ b/src/org/apache/fop/layout/RelativePositionProps.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; /** @@ -12,6 +55,7 @@ package org.apache.fop.layout; * Public "structure" allows direct member access. */ public class RelativePositionProps { + public int marginTop; public int marginBottom; public int marginLeft; @@ -21,6 +65,4 @@ public class RelativePositionProps { public int startIndent; public int endIndent; - public RelativePositionProps() {} - } diff --git a/src/org/apache/fop/layout/TextState.java b/src/org/apache/fop/layout/TextState.java index ab0a775d5..f41cf60e9 100644 --- a/src/org/apache/fop/layout/TextState.java +++ b/src/org/apache/fop/layout/TextState.java @@ -1,23 +1,63 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout; /** - * This class holds information about text-decoration - * + * This class holds information about text-decoration. */ public class TextState { - protected boolean underlined; - protected boolean overlined; - protected boolean linethrough; - - public TextState() {} + private boolean underlined; + private boolean overlined; + private boolean linethrough; /** * @return true if text should be underlined @@ -27,7 +67,8 @@ public class TextState { } /** - * set text as underlined + * Set text as underlined. + * @param ul true if underline should be enabled */ public void setUnderlined(boolean ul) { this.underlined = ul; @@ -40,14 +81,25 @@ public class TextState { return overlined; } + /** + * Set text as overlined. + * @param ol true if overline should be enabled + */ public void setOverlined(boolean ol) { this.overlined = ol; } + /** + * @return true if text should have a line through the middle + */ public boolean getLineThrough() { return linethrough; } + /** + * Controls if text should have a line through the middle. + * @param lt true if line through should be enabled + */ public void setLineThrough(boolean lt) { this.linethrough = lt; } diff --git a/src/org/apache/fop/layout/hyphenation/ByteVector.java b/src/org/apache/fop/layout/hyphenation/ByteVector.java index ecc9dd9a2..1e020e998 100644 --- a/src/org/apache/fop/layout/hyphenation/ByteVector.java +++ b/src/org/apache/fop/layout/hyphenation/ByteVector.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout.hyphenation; import java.io.Serializable; @@ -21,7 +64,7 @@ public class ByteVector implements Serializable { * Capacity increment size */ private static final int DEFAULT_BLOCK_SIZE = 2048; - private int BLOCK_SIZE; + private int blockSize; /** * The encapsulated array @@ -38,25 +81,27 @@ public class ByteVector implements Serializable { } public ByteVector(int capacity) { - if (capacity > 0) - BLOCK_SIZE = capacity; - else - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; - array = new byte[BLOCK_SIZE]; + if (capacity > 0) { + blockSize = capacity; + } else { + blockSize = DEFAULT_BLOCK_SIZE; + } + array = new byte[blockSize]; n = 0; } public ByteVector(byte[] a) { - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; + blockSize = DEFAULT_BLOCK_SIZE; array = a; n = 0; } public ByteVector(byte[] a, int capacity) { - if (capacity > 0) - BLOCK_SIZE = capacity; - else - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; + if (capacity > 0) { + blockSize = capacity; + } else { + blockSize = DEFAULT_BLOCK_SIZE; + } array = a; n = 0; } @@ -94,7 +139,7 @@ public class ByteVector implements Serializable { int index = n; int len = array.length; if (n + size >= len) { - byte[] aux = new byte[len + BLOCK_SIZE]; + byte[] aux = new byte[len + blockSize]; System.arraycopy(array, 0, aux, 0, len); array = aux; } diff --git a/src/org/apache/fop/layout/hyphenation/CharVector.java b/src/org/apache/fop/layout/hyphenation/CharVector.java index b91ae7dcb..13464570a 100644 --- a/src/org/apache/fop/layout/hyphenation/CharVector.java +++ b/src/org/apache/fop/layout/hyphenation/CharVector.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout.hyphenation; import java.io.Serializable; @@ -21,7 +64,7 @@ public class CharVector implements Cloneable, Serializable { * Capacity increment size */ private static final int DEFAULT_BLOCK_SIZE = 2048; - private int BLOCK_SIZE; + private int blockSize; /** * The encapsulated array @@ -38,25 +81,27 @@ public class CharVector implements Cloneable, Serializable { } public CharVector(int capacity) { - if (capacity > 0) - BLOCK_SIZE = capacity; - else - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; - array = new char[BLOCK_SIZE]; + if (capacity > 0) { + blockSize = capacity; + } else { + blockSize = DEFAULT_BLOCK_SIZE; + } + array = new char[blockSize]; n = 0; } public CharVector(char[] a) { - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; + blockSize = DEFAULT_BLOCK_SIZE; array = a; n = a.length; } public CharVector(char[] a, int capacity) { - if (capacity > 0) - BLOCK_SIZE = capacity; - else - BLOCK_SIZE = DEFAULT_BLOCK_SIZE; + if (capacity > 0) { + blockSize = capacity; + } else { + blockSize = DEFAULT_BLOCK_SIZE; + } array = a; n = a.length; } @@ -69,7 +114,7 @@ public class CharVector implements Cloneable, Serializable { } public Object clone() { - CharVector cv = new CharVector((char[])array.clone(), BLOCK_SIZE); + CharVector cv = new CharVector((char[])array.clone(), blockSize); cv.n = this.n; return cv; } @@ -104,7 +149,7 @@ public class CharVector implements Cloneable, Serializable { int index = n; int len = array.length; if (n + size >= len) { - char[] aux = new char[len + BLOCK_SIZE]; + char[] aux = new char[len + blockSize]; System.arraycopy(array, 0, aux, 0, len); array = aux; } diff --git a/src/org/apache/fop/layout/hyphenation/Hyphen.java b/src/org/apache/fop/layout/hyphenation/Hyphen.java index d93c3dd85..c5ee3efe8 100644 --- a/src/org/apache/fop/layout/hyphenation/Hyphen.java +++ b/src/org/apache/fop/layout/hyphenation/Hyphen.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout.hyphenation; import java.io.Serializable; @@ -40,9 +83,12 @@ public class Hyphen implements Serializable { } public String toString() { - if (noBreak == null && postBreak == null && preBreak != null - && preBreak.equals("-")) + if (noBreak == null + && postBreak == null + && preBreak != null + && preBreak.equals("-")) { return "-"; + } StringBuffer res = new StringBuffer("{"); res.append(preBreak); res.append("}{"); diff --git a/src/org/apache/fop/layout/hyphenation/Hyphenation.java b/src/org/apache/fop/layout/hyphenation/Hyphenation.java index 016091a4c..2038a9bda 100644 --- a/src/org/apache/fop/layout/hyphenation/Hyphenation.java +++ b/src/org/apache/fop/layout/hyphenation/Hyphenation.java @@ -1,27 +1,69 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout.hyphenation; -import java.util.Vector; - /** * This class represents a hyphenated word. * * @author Carlos Villegas <cav@uniscope.co.jp> */ public class Hyphenation { - int[] hyphenPoints; - String word; + + private int[] hyphenPoints; + private String word; /** * number of hyphenation points in word */ - int len; + private int len; /** * rawWord as made of alternating strings and {@link Hyphen Hyphen} diff --git a/src/org/apache/fop/layout/hyphenation/HyphenationException.java b/src/org/apache/fop/layout/hyphenation/HyphenationException.java index 442673512..9f68b01d2 100644 --- a/src/org/apache/fop/layout/hyphenation/HyphenationException.java +++ b/src/org/apache/fop/layout/hyphenation/HyphenationException.java @@ -1,17 +1,64 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout.hyphenation; /** * @author Carlos Villegas <cav@uniscope.co.jp> + * @todo Derive from FOPException */ public class HyphenationException extends Exception { + /** + * @see java.lang.Throwable#Throwable(String) + */ public HyphenationException(String msg) { super(msg); } diff --git a/src/org/apache/fop/layout/hyphenation/HyphenationTree.java b/src/org/apache/fop/layout/hyphenation/HyphenationTree.java index 8ce4a021b..6a99477d7 100644 --- a/src/org/apache/fop/layout/hyphenation/HyphenationTree.java +++ b/src/org/apache/fop/layout/hyphenation/HyphenationTree.java @@ -1,13 +1,63 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout.hyphenation; -import java.io.*; +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; @@ -18,8 +68,8 @@ import java.util.HashMap; * * @author Carlos Villegas <cav@uniscope.co.jp> */ -public class HyphenationTree extends TernaryTree implements PatternConsumer, - Serializable { +public class HyphenationTree extends TernaryTree + implements PatternConsumer, Serializable { /** * value space: stores the inteletter values @@ -65,10 +115,11 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, for (i = 0; i < n; i++) { int j = i >> 1; byte v = (byte)((values.charAt(i) - '0' + 1) & 0x0f); - if ((i & 1) == 1) + if ((i & 1) == 1) { va[j + offset] = (byte)(va[j + offset] | v); - else + } else { va[j + offset] = (byte)(v << 4); // big endian + } } va[m - 1 + offset] = 0; // terminator return offset; @@ -81,8 +132,9 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, char c = (char)((v >>> 4) - 1 + '0'); buf.append(c); c = (char)(v & 0x0f); - if (c == 0) + if (c == 0) { break; + } c = (char)(c - 1 + '0'); buf.append(c); v = vspace.get(k++); @@ -111,8 +163,9 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, public String findPattern(String pat) { int k = super.find(pat); - if (k >= 0) + if (k >= 0) { return unpackValues(k); + } return ""; } @@ -121,11 +174,14 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, * t is a substring of s */ protected int hstrcmp(char[] s, int si, char[] t, int ti) { - for (; s[si] == t[ti]; si++, ti++) - if (s[si] == 0) + for (; s[si] == t[ti]; si++, ti++) { + if (s[si] == 0) { return 0; - if (t[ti] == 0) + } + } + if (t[ti] == 0) { return 0; + } return s[si] - t[ti]; } @@ -136,15 +192,17 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, char c = (char)((v >>> 4) - 1); buf.append(c); c = (char)(v & 0x0f); - if (c == 0) + if (c == 0) { break; + } c = (char)(c - 1); buf.append(c); v = vspace.get(k++); } byte[] res = new byte[buf.length()]; - for (int i = 0; i < res.length; i++) + for (int i = 0; i < res.length; i++) { res[i] = (byte)buf.charAt(i); + } return res; } @@ -185,8 +243,9 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, values = getValues(eq[p]); // data pointer is in eq[] int j = index; for (int k = 0; k < values.length; k++) { - if (j < il.length && values[k] > il[j]) + if (j < il.length && values[k] > il[j]) { il[j] = values[k]; + } j++; } } @@ -227,8 +286,9 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, */ } } - } else + } else { p = d < 0 ? lo[p] : hi[p]; + } } } @@ -288,8 +348,9 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, Object o = hw.get(i); if (o instanceof String) { j += ((String)o).length(); - if (j >= remainCharCount && j < (len - pushCharCount)) + if (j >= remainCharCount && j < (len - pushCharCount)) { result[k++] = j; + } } } } else { @@ -388,9 +449,17 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, HyphenationTree ht = null; int minCharCount = 2; BufferedReader in = - new BufferedReader(new InputStreamReader(System.in)); - for (; ; ) { - System.out.print("l:\tload patterns from XML\nL:\tload patterns from serialized object\ns:\tset minimun character count\nw:\twrite hyphenation tree to object file\nh:\thyphenate\nf:\tfind pattern\nb:\tbenchmark\nq:\tquit\n\nCommand:"); + new BufferedReader(new java.io.InputStreamReader(System.in)); + while (true) { + System.out.print("l:\tload patterns from XML\n" + + "L:\tload patterns from serialized object\n" + + "s:\tset minimun character count\n" + + "w:\twrite hyphenation tree to object file\n" + + "h:\thyphenate\n" + + "f:\tfind pattern\n" + + "b:\tbenchmark\n" + + "q:\tquit\n\n" + + "Command:"); String token = in.readLine().trim(); if (token.equals("f")) { System.out.print("Pattern: "); @@ -414,12 +483,13 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, ht = (HyphenationTree)ois.readObject(); } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { if (ois != null) { try { ois.close(); - } catch (IOException e) {} + } catch (IOException e) { + //ignore + } } } } else if (token.equals("w")) { @@ -431,15 +501,18 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, oos.writeObject(ht); } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { if (oos != null) { try { oos.flush(); - } catch (IOException e) {} + } catch (IOException e) { + //ignore + } try { oos.close(); - } catch (IOException e) {} + } catch (IOException e) { + //ignore + } } } } else if (token.equals("h")) { @@ -486,8 +559,9 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, System.out.println(counter + " words in " + result + " Millisekunden hyphenated"); - } else if (token.equals("q")) + } else if (token.equals("q")) { break; + } } } diff --git a/src/org/apache/fop/layout/hyphenation/Hyphenator.java b/src/org/apache/fop/layout/hyphenation/Hyphenator.java index 3b6b540b5..cba22c3ac 100644 --- a/src/org/apache/fop/layout/hyphenation/Hyphenator.java +++ b/src/org/apache/fop/layout/hyphenation/Hyphenator.java @@ -1,13 +1,61 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout.hyphenation; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; import java.util.Hashtable; /** @@ -17,7 +65,9 @@ import java.util.Hashtable; * @author Carlos Villegas <cav@uniscope.co.jp> */ public class Hyphenator { - static Hashtable hyphenTrees = new Hashtable(); + + /**@todo Don't use statics */ + private static Hashtable hyphenTrees = new Hashtable(); private HyphenationTree hyphenTree = null; private int remainCharCount = 2; @@ -35,13 +85,16 @@ public class Hyphenator { String country) { String key = lang; // check whether the country code has been used - if (country != null &&!country.equals("none")) + if (country != null && !country.equals("none")) { key += "_" + country; - // first try to find it in the cache - if (hyphenTrees.containsKey(key)) + } + // first try to find it in the cache + if (hyphenTrees.containsKey(key)) { return (HyphenationTree)hyphenTrees.get(key); - if (hyphenTrees.containsKey(lang)) + } + if (hyphenTrees.containsKey(lang)) { return (HyphenationTree)hyphenTrees.get(lang); + } HyphenationTree hTree = getFopHyphenationTree(key); if (hTree == null) { @@ -54,6 +107,7 @@ public class Hyphenator { if (hTree != null) { hyphenTrees.put(key, hTree); } else { + /**@todo Proper logging please */ //log.error("Couldn't find hyphenation pattern " // + key); } @@ -73,7 +127,9 @@ public class Hyphenator { is = contextClassLoader.getResourceAsStream("hyph/" + key + ".hyp"); } - } catch (Exception e) {} + } catch (Exception e) { + //ignore, fallback further down + } if (is == null) { is = Hyphenator.class.getResourceAsStream("/hyph/" + key @@ -118,9 +174,9 @@ public class Hyphenator { ois = new ObjectInputStream(is); hTree = (HyphenationTree)ois.readObject(); } catch (Exception e) { + /**@todo proper logging please */ e.printStackTrace(); - } - finally { + } finally { if (ois != null) { try { ois.close(); @@ -149,16 +205,19 @@ public class Hyphenator { if (hyphenFile.exists()) { ObjectInputStream ois = null; try { - ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(hyphenFile))); + ois = new ObjectInputStream(new BufferedInputStream( + new FileInputStream(hyphenFile))); hTree = (HyphenationTree)ois.readObject(); } catch (Exception e) { + /**@todo Proper logging please */ e.printStackTrace(); - } - finally { + } finally { if (ois != null) { try { ois.close(); - } catch (IOException e) {} + } catch (IOException e) { + //ignore + } } } return hTree; @@ -236,15 +295,17 @@ public class Hyphenator { } public Hyphenation hyphenate(char[] word, int offset, int len) { - if (hyphenTree == null) + if (hyphenTree == null) { return null; + } return hyphenTree.hyphenate(word, offset, len, remainCharCount, pushCharCount); } public Hyphenation hyphenate(String word) { - if (hyphenTree == null) + if (hyphenTree == null) { return null; + } return hyphenTree.hyphenate(word, remainCharCount, pushCharCount); } diff --git a/src/org/apache/fop/layout/hyphenation/PatternConsumer.java b/src/org/apache/fop/layout/hyphenation/PatternConsumer.java index 025d82b0f..97529756a 100644 --- a/src/org/apache/fop/layout/hyphenation/PatternConsumer.java +++ b/src/org/apache/fop/layout/hyphenation/PatternConsumer.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout.hyphenation; import java.util.ArrayList; @@ -22,8 +65,9 @@ public interface PatternConsumer { * A character class defines characters that are considered * equivalent for the purpose of hyphenation (e.g. "aA"). It * usually means to ignore case. + * @param chargroup character group */ - public void addClass(String chargroup); + void addClass(String chargroup); /** * Add a hyphenation exception. An exception replaces the @@ -32,14 +76,14 @@ public interface PatternConsumer { * A hyphenatedword is a vector of alternating String's and * {@link Hyphen Hyphen} instances */ - public void addException(String word, ArrayList hyphenatedword); + void addException(String word, ArrayList hyphenatedword); /** * Add hyphenation patterns. - * @param pattern + * @param pattern the pattern * @param values interletter values expressed as a string of * digit characters. */ - public void addPattern(String pattern, String values); + void addPattern(String pattern, String values); } diff --git a/src/org/apache/fop/layout/hyphenation/PatternParser.java b/src/org/apache/fop/layout/hyphenation/PatternParser.java index 423318166..ac34ae60b 100644 --- a/src/org/apache/fop/layout/hyphenation/PatternParser.java +++ b/src/org/apache/fop/layout/hyphenation/PatternParser.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout.hyphenation; // SAX @@ -118,10 +161,12 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { File file = new File(filename); String path = file.getAbsolutePath(); String fSep = System.getProperty("file.separator"); - if (fSep != null && fSep.length() == 1) + if (fSep != null && fSep.length() == 1) { path = path.replace(fSep.charAt(0), '/'); - if (path.length() > 0 && path.charAt(0) != '/') + } + if (path.length() > 0 && path.charAt(0) != '/') { path = '/' + path; + } try { return new InputSource(new URL("file", null, path).toString()); } catch (java.net.MalformedURLException e) { @@ -133,15 +178,18 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { String word; boolean space = false; int i; - for (i = 0; i < chars.length(); i++) - if (Character.isWhitespace(chars.charAt(i))) + for (i = 0; i < chars.length(); i++) { + if (Character.isWhitespace(chars.charAt(i))) { space = true; - else + } else { break; + } + } if (space) { // chars.delete(0,i); - for (int countr = i; countr < chars.length(); countr++) + for (int countr = i; countr < chars.length(); countr++) { chars.setCharAt(countr - i, chars.charAt(countr)); + } chars.setLength(chars.length() - i); if (token.length() > 0) { word = token.toString(); @@ -158,8 +206,9 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { } token.append(chars.toString().substring(0, i)); // chars.delete(0,i); - for (int countr = i; countr < chars.length(); countr++) + for (int countr = i; countr < chars.length(); countr++) { chars.setCharAt(countr - i, chars.charAt(countr)); + } chars.setLength(chars.length() - i); if (space) { word = token.toString(); @@ -173,9 +222,11 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { protected static String getPattern(String word) { StringBuffer pat = new StringBuffer(); int len = word.length(); - for (int i = 0; i < len; i++) - if (!Character.isDigit(word.charAt(i))) + for (int i = 0; i < len; i++) { + if (!Character.isDigit(word.charAt(i))) { pat.append(word.charAt(i)); + } + } return pat.toString(); } @@ -188,9 +239,9 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { StringBuffer buf = new StringBuffer(); for (int j = 0; j < str.length(); j++) { char c = str.charAt(j); - if (c != hyphenChar) + if (c != hyphenChar) { buf.append(c); - else { + } else { res.add(buf.toString()); buf.setLength(0); char[] h = new char[1]; @@ -200,10 +251,12 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { res.add(new Hyphen(new String(h), null, null)); } } - if (buf.length() > 0) + if (buf.length() > 0) { res.add(buf.toString()); - } else + } + } else { res.add(item); + } } return res; } @@ -212,11 +265,12 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { StringBuffer res = new StringBuffer(); for (int i = 0; i < ex.size(); i++) { Object item = ex.get(i); - if (item instanceof String) + if (item instanceof String) { res.append((String)item); - else { - if (((Hyphen)item).noBreak != null) + } else { + if (((Hyphen)item).noBreak != null) { res.append(((Hyphen)item).noBreak); + } } } return res.toString(); @@ -231,8 +285,9 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { if (Character.isDigit(c)) { il.append(c); i++; - } else + } else { il.append('0'); + } } return il.toString(); } @@ -248,13 +303,14 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { Attributes attrs) { if (local.equals("hyphen-char")) { String h = attrs.getValue("value"); - if (h != null && h.length() == 1) + if (h != null && h.length() == 1) { hyphenChar = h.charAt(0); - } else if (local.equals("classes")) + } + } else if (local.equals("classes")) { currElement = ELEM_CLASSES; - else if (local.equals("patterns")) + } else if (local.equals("patterns")) { currElement = ELEM_PATTERNS; - else if (local.equals("exceptions")) { + } else if (local.equals("exceptions")) { currElement = ELEM_EXCEPTIONS; exception = new ArrayList(); } else if (local.equals("hyphen")) { @@ -291,13 +347,15 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { // nothing to do break; } - if (currElement != ELEM_HYPHEN) + if (currElement != ELEM_HYPHEN) { token.setLength(0); + } } - if (currElement == ELEM_HYPHEN) + if (currElement == ELEM_HYPHEN) { currElement = ELEM_EXCEPTIONS; - else + } else { currElement = 0; + } } @@ -368,8 +426,9 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { String systemId = ex.getSystemId(); if (systemId != null) { int index = systemId.lastIndexOf('/'); - if (index != -1) + if (index != -1) { systemId = systemId.substring(index + 1); + } str.append(systemId); } str.append(':'); diff --git a/src/org/apache/fop/layout/hyphenation/TernaryTree.java b/src/org/apache/fop/layout/hyphenation/TernaryTree.java index 11013f723..b80eb8f03 100644 --- a/src/org/apache/fop/layout/hyphenation/TernaryTree.java +++ b/src/org/apache/fop/layout/hyphenation/TernaryTree.java @@ -1,10 +1,53 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, 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 Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * 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 + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, 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. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.layout.hyphenation; import java.util.Enumeration; @@ -128,8 +171,9 @@ public class TernaryTree implements Cloneable, Serializable { // make sure we have enough room in the arrays int len = key.length() + 1; // maximum number of nodes that may be generated - if (freenode + len > eq.length) + if (freenode + len > eq.length) { redimNodeArrays(eq.length + BLOCK_SIZE); + } char strkey[] = new char[len--]; key.getChars(0, len, strkey, 0); strkey[len] = 0; @@ -138,8 +182,9 @@ public class TernaryTree implements Cloneable, Serializable { public void insert(char[] key, int start, char val) { int len = strlen(key) + 1; - if (freenode + len > eq.length) + if (freenode + len > eq.length) { redimNodeArrays(eq.length + BLOCK_SIZE); + } root = insert(root, key, start, val); } @@ -185,9 +230,10 @@ public class TernaryTree implements Cloneable, Serializable { lo[pp] = 0; sc[pp] = 0; hi[pp] = 0; - } else - sc[pp] = - 0xFFFF; // we only got first char of key, rest is still there + } else { + // we only got first char of key, rest is still there + sc[pp] = 0xFFFF; + } } else { // In this case we can save a node by swapping the new node // with the compressed node @@ -200,18 +246,18 @@ public class TernaryTree implements Cloneable, Serializable { } } char s = key[start]; - if (s < sc[p]) + if (s < sc[p]) { lo[p] = insert(lo[p], key, start, val); - else if (s == sc[p]) { - if (s != 0) + } else if (s == sc[p]) { + if (s != 0) { eq[p] = insert(eq[p], key, start + 1, val); - else { + } else { // key already in tree, overwrite data eq[p] = val; } - - } else + } else { hi[p] = insert(hi[p], key, start, val); + } return p; } @@ -219,9 +265,11 @@ public class TernaryTree implements Cloneable, Serializable { * Compares 2 null terminated char arrays */ public static int strcmp(char[] a, int startA, char[] b, int startB) { - for (; a[startA] == b[startB]; startA++, startB++) - if (a[startA] == 0) + for (; a[startA] == b[startB]; startA++, startB++) { + if (a[startA] == 0) { return 0; + } + } return a[startA] - b[startB]; } @@ -232,27 +280,32 @@ public class TernaryTree implements Cloneable, Serializable { int i, d, len = str.length(); for (i = 0; i < len; i++) { d = (int)str.charAt(i) - a[start + i]; - if (d != 0) + if (d != 0) { return d; - if (a[start + i] == 0) + } + if (a[start + i] == 0) { return d; + } } - if (a[start + i] != 0) + if (a[start + i] != 0) { return (int)-a[start + i]; + } return 0; } public static void strcpy(char[] dst, int di, char[] src, int si) { - while (src[si] != 0) + while (src[si] != 0) { dst[di++] = src[si++]; + } dst[di] = 0; } public static int strlen(char[] a, int start) { int len = 0; - for (int i = start; i < a.length && a[i] != 0; i++) + for (int i = start; i < a.length && a[i] != 0; i++) { len++; + } return len; } @@ -277,22 +330,25 @@ public class TernaryTree implements Cloneable, Serializable { while (p != 0) { if (sc[p] == 0xFFFF) { - if (strcmp(key, i, kv.getArray(), lo[p]) == 0) + if (strcmp(key, i, kv.getArray(), lo[p]) == 0) { return eq[p]; - else + } else { return -1; + } } c = key[i]; d = c - sc[p]; if (d == 0) { - if (c == 0) + if (c == 0) { return eq[p]; + } i++; p = eq[p]; - } else if (d < 0) + } else if (d < 0) { p = lo[p]; - else + } else { p = hi[p]; + } } return -1; } @@ -344,8 +400,9 @@ public class TernaryTree implements Cloneable, Serializable { */ protected void insertBalanced(String[] k, char[] v, int offset, int n) { int m; - if (n < 1) + if (n < 1) { return; + } m = n >> 1; insert(k[m + offset], v[m + offset]); @@ -407,8 +464,9 @@ public class TernaryTree implements Cloneable, Serializable { private void compact(CharVector kx, TernaryTree map, char p) { int k; - if (p == 0) + if (p == 0) { return; + } if (sc[p] == 0xFFFF) { k = map.find(kv.getArray(), lo[p]); if (k < 0) { @@ -419,8 +477,9 @@ public class TernaryTree implements Cloneable, Serializable { lo[p] = (char)k; } else { compact(kx, map, lo[p]); - if (sc[p] != 0) + if (sc[p] != 0) { compact(kx, map, eq[p]); + } compact(kx, map, hi[p]); } } @@ -494,8 +553,9 @@ public class TernaryTree implements Cloneable, Serializable { } public char getValue() { - if (cur >= 0) + if (cur >= 0) { return eq[cur]; + } return 0; } @@ -510,11 +570,13 @@ public class TernaryTree implements Cloneable, Serializable { Item i = new Item(); int res = 0; - if (ns.empty()) + if (ns.empty()) { return -1; + } - if (cur != 0 && sc[cur] == 0) + if (cur != 0 && sc[cur] == 0) { return lo[cur]; + } boolean climb = true; @@ -538,14 +600,16 @@ public class TernaryTree implements Cloneable, Serializable { case 2: res = hi[i.parent]; ns.push(i.clone()); - if (ks.length() > 0) + if (ks.length() > 0) { ks.setLength(ks.length() - 1); // pop + } climb = false; break; default: - if (ns.empty()) + if (ns.empty()) { return -1; + } climb = true; break; } @@ -557,11 +621,12 @@ public class TernaryTree implements Cloneable, Serializable { * traverse the tree to find next key */ private int run() { - if (cur == -1) + if (cur == -1) { return -1; + } boolean leaf = false; - for (; ; ) { + while (true) { // first go down on low branch until leaf or compressed branch while (cur != 0) { if (sc[cur] == 0xFFFF) { @@ -575,9 +640,10 @@ public class TernaryTree implements Cloneable, Serializable { } cur = lo[cur]; } - if (leaf) + if (leaf) { break; - // nothing found, go up one node and try again + } + // nothing found, go up one node and try again cur = up(); if (cur == -1) { return -1; @@ -588,8 +654,9 @@ public class TernaryTree implements Cloneable, Serializable { StringBuffer buf = new StringBuffer(ks.toString()); if (sc[cur] == 0xFFFF) { int p = lo[cur]; - while (kv.get(p) != 0) + while (kv.get(p) != 0) { buf.append(kv.get(p++)); + } } curkey = buf.toString(); return 0; |