Package org.albite.io.decoders

Examples of org.albite.io.decoders.AlbiteStreamReader


//          utf8Decoder.reset();
//          char [] characters = utf8Decoder.decode(bufferBuffer).array();
//          char [] characters = utf8Decoder.decode(bufferBuffer).array();
         
          ByteArrayInputStream in = new ByteArrayInputStream(buffer);
          AlbiteStreamReader r =
                  new AlbiteStreamReader(in, Encodings.UTF_8);
          char[] characters = r.read(buffer.length);
          result = String.valueOf(characters);
        }
      return result;
    }
View Full Code Here


            Document doc = null;
            Element root;
            Element kid;
            try {
                parser = new KXmlParser();
                parser.setInput(new AlbiteStreamReader(
                        in, Encodings.DEFAULT));

                doc = new Document();
                doc.parse(parser);
                parser = null;

                root = doc.getRootElement();

                Element rfile = root
                        .getElement(KXmlParser.NO_NAMESPACE, "rootfiles")
                        .getElement(KXmlParser.NO_NAMESPACE, "rootfile");

                opfFileName = rfile.getAttributeValue(
                        KXmlParser.NO_NAMESPACE, "full-path");

                if (opfFileName == null) {
                    throw new BookException("Missing opf file");
                }

                opfFilePath = RandomReadingFile.getPathFromURL(opfFileName);

                //#debug
                AlbiteMIDlet.LOGGER.log(opfFilePath);

            } catch (XmlPullParserException xppe) {
                parser = null;
                doc = null;
                throw new BookException(
                    "container.xml is invalid");
            }
        } finally {
            in.close();
        }

        /*
         * now the opf file
         */
        ArchiveEntry opfFile = bookArchive.getEntry(opfFileName);

        if (opfFile == null) {
            throw new BookException("Missing opf");
        }

        in = opfFile.openInputStream();

        try {
            KXmlParser parser = null;
            Document doc = null;
            Element root;
            Element kid;

            try {
                parser = new KXmlParser();

                try {
                    parser.setFeature(
                            KXmlParser.FEATURE_PROCESS_NAMESPACES, true);
                } catch (XmlPullParserException e) {}

                parser.setInput(new AlbiteStreamReader(
                        in, Encodings.DEFAULT));

                doc = new Document();
                doc.parse(parser);
                parser = null;
View Full Code Here

    public final char[] getTextBuffer() {
        if (textBuffer == null) {
            try {
                InputStream in = file.openInputStream();
                Reader r = null;
                AlbiteStreamReader asr = null;

                final boolean auto =
                        AUTO_ENCODING.equalsIgnoreCase(currentEncoding);

                if (auto) {
                    currentEncoding = Encodings.DEFAULT;
                }

                if (processHtmlEntities) {
                    if (!in.markSupported()) {
                        in = new BufferedInputStream(in);
                    }

                    /*
                     * Warning: if the XhtmlStreamReader is not used,
                     * then the HtmlParser won't work, as
                     * it relies on modified versions of '<' and '>'
                     */
                    asr = new AlbiteStreamReader(in, currentEncoding);
                    r = new XhtmlStreamReader(asr, auto, true);
                } else {
                    asr = new AlbiteStreamReader(in, currentEncoding);
                    r = asr;
                }

                try {
                    textBuffer = new char[fileSize];
                    int read = r.read(textBuffer);

                    if (read == -1) {
                        return new char[0];
                    }

                    if (read < fileSize) {
                        char[] res = new char[read];
                        System.arraycopy(textBuffer, 0, res, 0, read);
                        textBuffer = res;
                    }

                    currentEncoding = asr.getEncoding();

                } catch (IOException e) {
                    //#debug
                    AlbiteMIDlet.LOGGER.log(e);
                    textBuffer = new char[0];
View Full Code Here

TOP

Related Classes of org.albite.io.decoders.AlbiteStreamReader

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.