Package javax.xml.stream

Examples of javax.xml.stream.XMLStreamException


        }
    }
   
    protected void fillBuf() throws XMLStreamException, EOFException {
       
        if(reader == null) throw new XMLStreamException(
                "reader must be set before parsing is started");
       
        // see if we are in compaction area
        if(bufEnd > bufSoftLimit) {
           
            // expand buffer it makes sense!!!!
            boolean compact = bufStart > bufSoftLimit;
            boolean expand = false;
            if(!compact) {
                //freeSpace
                if(bufStart < buf.length / 2) {
                    // less then half buffer available for compacting --> expand instead!!!
                    expand = true;
                } else {
                    // at least half of buffer can be reclaimed --> worthwhile effort!!!
                    compact = true;
                }
            }
           
            // if buffer almost full then compact it
            if(compact) {
                //TODO: look on trashing
                // //assert bufStart > 0
                System.arraycopy(buf, bufStart, buf, 0, bufEnd - bufStart);
                if(TRACE_SIZING) System.out.println("fillBuf() compacting "+bufStart);
               
            } else if(expand) {
                int newSize = 2 * buf.length;
                char newBuf[] = new char[ newSize ];
                if(TRACE_SIZING) System.out.println("fillBuf() "+buf.length+" => "+newSize);
                System.arraycopy(buf, bufStart, newBuf, 0, bufEnd - bufStart);
                buf = newBuf;
                if(bufLoadFactor > 0) {
                    bufSoftLimit = ( bufLoadFactor * buf.length ) /100;
                }
               
            } else {
                throw new XMLStreamException("internal error in fillBuffer()");
            }
            bufEnd -= bufStart;
            pos -= bufStart;
            posStart -= bufStart;
            posEnd -= bufStart;
            bufAbsoluteStart += bufStart;
            bufStart = 0;
        }
        // at least one character must be read or error
        int room = (buf.length - bufEnd);
        int len = (room > READ_CHUNK_SIZE) ? READ_CHUNK_SIZE : room;
        int ret;

        try {
            ret = reader.read(buf, bufEnd, len);
        } catch (IOException ioe) {
            throw new XMLStreamException(ioe);
        }
        if(ret > 0) {
            bufEnd += ret;
            return;
        }
        if(ret == -1) {
            throw new EOFException("no more data available");
        } else {
            throw new XMLStreamException("error reading input, returned "+ret);
        }
       
    }
View Full Code Here


    }

    private void throwNotNameStart(char ch)
        throws XMLStreamException
    {
        throw new XMLStreamException("expected name start character and not "+printable(ch), getLocation());
    }
View Full Code Here

    throws XMLStreamException
  {
    try {
    return createXMLStreamWriter(new java.io.OutputStreamWriter(stream,encoding));
    } catch (java.io.UnsupportedEncodingException uee) {
      throw new XMLStreamException("Unsupported encoding "+encoding,uee);
    }
  }
View Full Code Here

  public XMLEvent nextTag() throws XMLStreamException {
    while(hasNext()) {
      XMLEvent e = nextEvent();
      if (e.isCharacters() && !((Characters) e).isWhiteSpace())
        throw new XMLStreamException("Unexpected text");
      if (e.isStartElement() || e.isEndElement())
        return e;
    }
    throw new XMLStreamException("Unexpected end of Document");
  }
View Full Code Here

        throws XMLStreamException
    {
        try {
            writer.write(s);
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here

        throws XMLStreamException
    {
        try {
            writer.write(c);
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here

        throws XMLStreamException
    {
        try {
            writer.write(c);
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here

        throws XMLStreamException
    {
        try {
            writer.write(c,start,len);
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here

        Iterator i = needToWrite.iterator();
        while (i.hasNext()) {
            String uri = (String) i.next();
            String prefix = context.getPrefix(uri);
            if (prefix == null) {
                throw new XMLStreamException("Unable to default prefix with uri:"+
                                             uri);
            }
            writeNamespace(prefix,uri);
        }
        needToWrite.clear();
View Full Code Here

    }
    public void flush() throws XMLStreamException {
        try {
            writer.flush();
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here

TOP

Related Classes of javax.xml.stream.XMLStreamException

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.