Package org.axsl.hyphen

Examples of org.axsl.hyphen.HyphenationException


    MorphHyphenation(final String word, final byte[] points,
            final byte[] values, final int qtySpecialBreaks)
            throws HyphenationException {
        super(word, points, values);
        if (qtySpecialBreaks < 1) {
            throw new HyphenationException("Number of special hyphenation "
                    + "breaks must be greater than zero.");
        }
        this.indexes = new int[qtySpecialBreaks];
        this.breaks = new HyphenBreak4a[qtySpecialBreaks];
    }
View Full Code Here


        try {
            hyphenFile = URLFactory.createURL(this.hyphenationDir, fileName);
        } catch (final MalformedURLException e) {
            /* This probably means that the hyphenation URL is not valid.
             * Rethrow the exception to alert the user. */
            throw new HyphenationException(e);
        }

        InputStream inputStream = null;
        try {
            inputStream = hyphenFile.openStream();
        } catch (final IOException e) {
            /* This just means that the pattern doesn't exist. Ignore the
             * exception as the null value in "inputStream" will control the
             * downstream logic. */
        }

        if (inputStream != null) {
            ObjectInputStream ois = null;
            try {
                ois = new ObjectInputStream(inputStream);
                hTree = (HyphenationTree) ois.readObject();
                return hTree;
            } catch (final IOException e) {
                throw new HyphenationException(e);
            } catch (final ClassNotFoundException e) {
                throw new HyphenationException(e);
            } finally {
                if (ois != null) {
                    try {
                        ois.close();
                    } catch (final IOException e) {
                        this.logger.error("Exception closing ObjectInputStream "
                                + "for " + hyphenFile.toString(), e);
                    }
                }
            }
        }


        /* Look for the raw XML file. */
        fileName = key + ".xml";
        try {
            hyphenFile = URLFactory.createURL(this.hyphenationDir, fileName);
        } catch (final MalformedURLException e) {
            /* This probably means that the hyphenation URL is not valid.
             * Rethrow the exception to alert the user. */
            throw new HyphenationException(e);
        }

        /* Does the XML file exist? */
        try {
            inputStream = hyphenFile.openStream();
View Full Code Here

        try {
            nlFile = URLFactory.createURL(naturalLanguageDir, fileName);
        } catch (final MalformedURLException e) {
            /* This probably means that the hyphenation URL is not valid.
             * Rethrow the exception to alert the user. */
            throw new HyphenationException(e);
        }

        InputStream inputStream = null;
        try {
            inputStream = nlFile.openStream();
        } catch (final IOException e) {
            /* This just means that the input doesn't exist. Ignore the
             * exception as the null value in "inputStream" will control the
             * downstream logic. */
        }

        if (inputStream != null) {
            ObjectInputStream ois = null;
            try {
                ois = new ObjectInputStream(inputStream);
                nl = (NaturalLanguage) ois.readObject();
                return nl;
            } catch (final IOException e) {
                throw new HyphenationException(e);
            } catch (final ClassNotFoundException e) {
                throw new HyphenationException(e);
            } finally {
                if (ois != null) {
                    try {
                        ois.close();
                    } catch (final IOException e) {
                        this.logger.error(
                                "Exception closing ObjectInputStream "
                                + "for " + nlFile.toString(), e);
                    }
                }
            }
        }


        /* Look for the raw XML file. */
        fileName = filePrefix + ".xml";
        try {
            nlFile = URLFactory.createURL(naturalLanguageDir, fileName);
        } catch (final MalformedURLException e) {
            /* This probably means that the hyphenation URL is not valid.
             * Rethrow the exception to alert the user. */
            throw new HyphenationException(e);
        }

        /* Does the XML file exist? */
        try {
            inputStream = nlFile.openStream();
View Full Code Here

     */
    public HyphenationServer4a makeHyphenationServer() throws HyphenationException {
        try {
            return TestHyphenationServer4a.makeHyphenationServerStatic();
        } catch (final IOException e) {
            throw new HyphenationException(e);
        }
    }
View Full Code Here

     * @throws HyphenationException For errors during construction.
     */
    public PatternParser(final PatternConsumer consumer, final Log logger)
            throws HyphenationException {
        if (logger == null) {
            throw new HyphenationException(this.getClass().getName()
                    + " requires a Log instance at construction.");
        }
        if (consumer == null) {
            throw new HyphenationException(this.getClass().getName()
                    + " requires a PatternConsumer instance at construction.");
        }
        this.logger = logger;
        this.token = new StringBuilder();
        this.parser = createParser();
View Full Code Here

        final InputSource uri = new InputSource(inputStream);

        try {
            this.parser.parse(uri);
        } catch (final SAXException e) {
            throw new HyphenationException(this.errMsg);
        } catch (final IOException e) {
            throw new HyphenationException(e.getMessage());
        } catch (final NullPointerException e) {
            throw new HyphenationException("SAX parser not available");
        }
    }
View Full Code Here

            parserClassName = "org.apache.xerces.parsers.SAXParser";
        }
        try {
            return (XMLReader) Class.forName(parserClassName).newInstance();
        } catch (final ClassNotFoundException e) {
            throw new HyphenationException("Could not find "
                                           + parserClassName);
        } catch (final InstantiationException e) {
            throw new HyphenationException("Could not instantiate "
                                           + parserClassName);
        } catch (final IllegalAccessException e) {
            throw new HyphenationException("Could not access "
                                           + parserClassName);
        } catch (final ClassCastException e) {
            throw new HyphenationException(parserClassName
                                           + " is not a SAX driver");
        }
    }
View Full Code Here

     * @throws HyphenationException For an invalid {@code liangValue}.
     */
    public static byte convertLiangToWeight(final byte liangValue)
            throws HyphenationException {
        if (liangValue < 0) {
            throw new HyphenationException("Invalid Liang input: "
                    + liangValue);
        }
        byte modifiedLiangValue = liangValue;
        /* Save the low-order bit. */
        final boolean good = (modifiedLiangValue & 1) == 1;
View Full Code Here

        final InputSource uri = new InputSource(inputStream);

        try {
            this.parser.parse(uri);
        } catch (final SAXException e) {
            throw new HyphenationException(this.errMsg);
        } catch (final IOException e) {
            throw new HyphenationException(e.getMessage());
        } catch (final NullPointerException e) {
            throw new HyphenationException("SAX parser not available");
        }
        return this.nl;
    }
View Full Code Here

        this.dictionaryPath = dictionary;
        this.patternsPath = patterns;
        this.translatePath = translate;
        this.patoutPath = patout;
        if (this.dictionaryPath == null) {
            throw new HyphenationException("Dictionary cannot be null.");
        }
        if (this.patoutPath == null) {
            throw new HyphenationException("Output cannot be null.");
        }
    }
View Full Code Here

TOP

Related Classes of org.axsl.hyphen.HyphenationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.