Package java.io

Examples of java.io.ObjectInput


    public Sequence<Item> decode() throws IOException, XQueryException {
        final XDMTreeBuilder handler = new XDMTreeBuilder();
        final List<Item> items = new ArrayList<Item>(256);
        boolean prevNodeStart = false;
        final ObjectInput input = _input;
        while(true) {
            final byte ev = input.readByte();
            if(ev == XQEventEncoder.EV_EOF) {
                handler.endItem(true);
                break;
            }
            switch(ev) {
                case XQEventEncoder.EV_ATOM: {
                    final AtomicValue atom;
                    try {
                        atom = AtomicValue.readAtomicValue(input);
                    } catch (ClassNotFoundException e) {
                        throw new IllegalStateException(e);
                    }
                    handler.evAtomicValue(atom);
                    items.add(atom);
                    break;
                }
                case XQEventEncoder.EV_DTM_NODE: {
                    final DTMNodeBase dtmNode;
                    try {
                        dtmNode = DTMNodeBase.readFrom(input, _serContext);
                    } catch (ClassNotFoundException e) {
                        throw new IllegalStateException(e);
                    }
                    items.add(dtmNode);
                    break;
                }
                case XQEventEncoder.EV_NODE_START:
                    prevNodeStart = true;
                    continue;
                case XQEventEncoder.EV_NODE_END: {
                    prevNodeStart = false;
                    handler.reset();
                    break;
                }
                case XQEventEncoder.EV_END_ITEM:
                    handler.endItem(false);
                    break;
                case XQEventEncoder.EV_START_DOC:
                    handler.evStartDocument();
                    break;
                case XQEventEncoder.EV_END_DOC:
                    handler.evEndDocument();
                    break;
                case XQEventEncoder.EV_START_ELEM: {
                    String prefix = readString(input);
                    String localName = readString(input);
                    String namespaceURI = readString(input);
                    handler.evStartElement(prefix, localName, namespaceURI);
                    break;
                }
                case XQEventEncoder.EV_END_ELEM: {
                    String prefix = readString(input);
                    String localName = readString(input);
                    String namespaceURI = readString(input);
                    handler.evEndElement(prefix, localName, namespaceURI);
                    break;
                }
                case XQEventEncoder.EV_ATTR: {
                    QualifiedName qname = QualifiedName.readFrom(input);
                    String value = readString(input);
                    handler.evAttribute(qname, value);
                    break;
                }
                case XQEventEncoder.EV_NAMESPACE: {
                    String prefix = readString(input);
                    String uri = readString(input);
                    handler.evNamespace(prefix, uri);
                    break;
                }
                case XQEventEncoder.EV_TEXT: {
                    final int length = input.readInt();
                    final char[] ch = new char[length];
                    for(int i = 0; i < length; i++) {
                        ch[i] = input.readChar();
                    }
                    handler.evText(ch, 0, length);
                    break;
                }
                case XQEventEncoder.EV_CDATA: {
                    final int length = input.readInt();
                    final char[] ch = new char[length];
                    for(int i = 0; i < length; i++) {
                        ch[i] = input.readChar();
                    }
                    handler.evCData(ch, 0, length);
                    break;
                }
                case XQEventEncoder.EV_COMMENT: {
                    final int length = input.readInt();
                    final char[] ch = new char[length];
                    for(int i = 0; i < length; i++) {
                        ch[i] = input.readChar();
                    }
                    handler.evComment(ch, 0, length);
                    break;
                }
                case XQEventEncoder.EV_PI: {
View Full Code Here


    /**
     * @param null if there are no items.
     */
    public Item decodeItem(final XDMTreeBuilder handler) throws IOException, XQueryException {
        final ObjectInput input = _input;
        while(true) {
            final byte ev = input.readByte();
            switch(ev) {
                case XQEventEncoder.EV_ATOM: {
                    final AtomicValue atom;
                    try {
                        atom = AtomicValue.readAtomicValue(input);
                    } catch (ClassNotFoundException e) {
                        throw new IllegalStateException(e);
                    }
                    return atom;
                }
                case XQEventEncoder.EV_DTM_NODE: {
                    final DTMNodeBase dtmNode;
                    try {
                        dtmNode = DTMNodeBase.readFrom(input, _serContext);
                    } catch (ClassNotFoundException e) {
                        throw new IllegalStateException(e);
                    }
                    return dtmNode;
                }
                case XQEventEncoder.EV_NODE_START:
                    final XQNode node = decodeNode(input, handler, _serContext);
                    return node;
                case XQEventEncoder.EV_TEXT: {
                    final int length = input.readInt();
                    final char[] ch = new char[length];
                    for(int i = 0; i < length; i++) {
                        ch[i] = input.readChar();
                    }
                    handler.evText(ch, 0, length);
                    break;
                }
                case XQEventEncoder.EV_END_ITEM:
View Full Code Here

            }
        }
    }

    public void redirectTo(ObjectOutput out) throws IOException {
        final ObjectInput input = _input;
        while(true) {
            final byte ev = input.readByte();
            out.writeByte(ev);
            if(ev == XQEventEncoder.EV_EOF) {
                return;
            }
            switch(ev) {
                case XQEventEncoder.EV_ATOM: {
                    final AtomicValue atom;
                    try {
                        atom = AtomicValue.readAtomicValue(input);
                    } catch (ClassNotFoundException e) {
                        throw new IllegalStateException(e);
                    }
                    AtomicValue.writeAtomicValue(atom, out);
                    break;
                }
                case XQEventEncoder.EV_DTM_NODE: {
                    try {
                        DTMNodeBase.redirect(input, out);
                    } catch (ClassNotFoundException e) {
                        throw new IllegalStateException(e);
                    }
                    break;
                }
                case XQEventEncoder.EV_NODE_START:
                    break;
                case XQEventEncoder.EV_NODE_END:
                    break;
                case XQEventEncoder.EV_START_DOC:
                    break;
                case XQEventEncoder.EV_END_DOC:
                    break;
                case XQEventEncoder.EV_START_ELEM: {
                    redirectString(input, out);
                    redirectString(input, out);
                    redirectString(input, out);
                    break;
                }
                case XQEventEncoder.EV_END_ELEM: {
                    redirectString(input, out);
                    redirectString(input, out);
                    redirectString(input, out);
                    break;
                }
                case XQEventEncoder.EV_ATTR: {
                    QualifiedName qname = QualifiedName.readFrom(input);
                    qname.writeExternal(out);
                    redirectString(input, out);
                    break;
                }
                case XQEventEncoder.EV_NAMESPACE:
                    redirectString(input, out);
                    redirectString(input, out);
                    break;
                case XQEventEncoder.EV_TEXT: {
                    final int length = input.readInt();
                    out.writeInt(length);
                    for(int i = 0; i < length; i++) {
                        char c = input.readChar();
                        out.writeChar(c);
                    }
                    break;
                }
                case XQEventEncoder.EV_CDATA: {
                    final int length = input.readInt();
                    out.writeInt(length);
                    for(int i = 0; i < length; i++) {
                        char c = input.readChar();
                        out.writeChar(c);
                    }
                    break;
                }
                case XQEventEncoder.EV_COMMENT: {
                    final int length = input.readInt();
                    out.writeInt(length);
                    for(int i = 0; i < length; i++) {
                        char c = input.readChar();
                        out.writeChar(c);
                    }
                    break;
                }
                case XQEventEncoder.EV_PI:
View Full Code Here

    }
   
    public MessageContext getContext(InputStream is) {
        MessageContext ctx = new GenericMessageContext();
        try {
            ObjectInput oi = new ObjectInputStream(is);
            int nKeys = oi.readInt();
           
            for (int i = 0; i < nKeys; i++) {
                String key = (String)oi.readObject();
                Object value = oi.readObject();
                ctx.put(key, value);
            }
           
            // construct SOAPMessage from input stream
           
View Full Code Here

        {
            throw new IntegrationException( "Rule Set jar does not contain a rule-set.conf file." );
        }
       
        InputStream is = null;
        ObjectInput in = null;
        RuleSet ruleSet = null;
        try
        {
            is = classLoader.getResourceAsStream( (String) props.get( "name" ) );
       
            in = new ObjectInputStreamWithLoader( is,
                                                  classLoader );
            ruleSet = (RuleSet) in.readObject();
        }
        catch (ClassNotFoundException e)
        {
            throw new IntegrationException( "Rule Set jar is not correctly formed." );
        }
        finally
        {
            if ( is != null )
            {
                is.close();
            }
            if ( in != null )
            {
                in.close();
            }
        }
        return ruleSet;
          
    }    
View Full Code Here

        addToClassLoader(functions, classLoader);
        addToClassLoader(others, classLoader);
        addToClassLoader(invokers, classLoader);
       
        ByteArrayInputStream bis = new ByteArrayInputStream( ruleSetBytes );
        ObjectInput in = new ObjectInputStreamWithLoader( bis,
          
                                                          classLoader );
        addRuleSetBinary( ruleSetBytes );
        try
        {
            RuleSet ruleSet = (RuleSet) in.readObject();
            addFromRuleSet( ruleSet );
        }
        catch ( ClassNotFoundException e )
        {
            throw new IntegrationException( "Rule Set jar is not correctly formed." );
        }
        catch ( IOException e )
        {
            throw new IntegrationException( "Rule Set jar is not correctly formed." );
       
        finally
        {
            if ( bis != null )
            {
                bis.close();
            }
            if ( in != null )
            {
                in.close();
            }
        }
                       
    }
View Full Code Here

        // Get the bytes of the serialized object
        byte[] bytes = bos.toByteArray( );

        // Deserialize from a byte array
        ObjectInput in = new ObjectInputStream(
                                                new ByteArrayInputStream( bytes ) );
        conflictResolver = ( ConflictResolver ) in.readObject( );
        in.close( );
    }
View Full Code Here

        // Get the bytes of the serialized object
        byte[] bytes = bos.toByteArray( );

        // Deserialize from a byte array
        ObjectInput in = new ObjectInputStream( new ByteArrayInputStream( bytes ) );
        in.readObject( );
        in.close( );

        // JSR-94 Tests
        // Reset the session. [ruleSession.reset();]
        WorkingMemory newWorkingMemory = ruleBase.newWorkingMemory( );
        assertNotNull("WMNotNullTest ", newWorkingMemory);
View Full Code Here

        // Get the bytes of the serialized object
        byte[] bytes = bos.toByteArray( );

        // Deserialize from a byte array
        ObjectInput in = new ObjectInputStream(
                                                new ByteArrayInputStream( bytes ) );
        conflictResolver = ( ConflictResolver ) in.readObject( );
        in.close( );
    }
View Full Code Here

        // Get the bytes of the serialized object
        byte[] bytes = bos.toByteArray( );

        // Deserialize from a byte array
        ObjectInput in = new ObjectInputStream(
                                                new ByteArrayInputStream( bytes ) );
        conflictResolver = ( ConflictResolver ) in.readObject( );
        in.close( );
    }
View Full Code Here

TOP

Related Classes of java.io.ObjectInput

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.