Package org.codehaus.jettison

Examples of org.codehaus.jettison.Node


                array.put(newCurrent);
               
                currentNode.put(currentKey, array);
               
                currentNode = newCurrent;
                Node node = new Node(currentNode);
                nodes.push(node);
            } else {
                JSONObject newCurrent = new JSONObject();
               
                if (existing instanceof JSONArray) {
                    ((JSONArray) existing).put(newCurrent);
                } else {
                    currentNode.put(currentKey, newCurrent);
                }
               
                currentNode = newCurrent;
                Node node = new Node(currentNode);
                nodes.push(node);
            }
        } catch (JSONException e) {
            throw new XMLStreamException("Could not write start element!", e);
        }
View Full Code Here


   
    public BadgerFishXMLStreamReader(JSONObject obj)
        throws JSONException, XMLStreamException {
        String rootName = (String) obj.keys().next();
       
        this.node = new Node(rootName, obj.getJSONObject(rootName), CONVENTION);
        this.nodes = new FastStack();
        nodes.push(node);
        event = START_DOCUMENT;
    }
View Full Code Here

                node = (Node) nodes.peek();
            }
           
            if (node.getArray() != null
                && node.getArray().length() > node.getArrayIndex()) {
                Node arrayNode = node;
                int idx = arrayNode.getArrayIndex();
               
                try {
                    Object o = arrayNode.getArray().get(idx);
                    processKey(node.getCurrentKey(), o);
                } catch (JSONException e) {
                    throw new XMLStreamException(e);
                }
               
                idx++;
                arrayNode.setArrayIndex(idx);
            } else if (node.getKeys() != null && node.getKeys().hasNext()) {
                processElement();
            } else {
                if (nodes.size() != 0) {
                    event = END_ELEMENT;
View Full Code Here

            event = CHARACTERS;
            // TODO I think there is a possibility this could be array
            currentText = (String) newObj;
            return;
        } else if (newObj instanceof JSONObject) {
            node = new Node(nextKey, (JSONObject) newObj, CONVENTION);
            nodes.push(node);
            event = START_ELEMENT;
            return;
        } else if (newObj instanceof JSONArray) {
            JSONArray arr = (JSONArray) newObj;
View Full Code Here

        this.convention = con;
        this.nodes = new FastStack();
        Object top = obj.get(rootName);
        if(top instanceof JSONObject) {
            this.node = new Node(rootName, (JSONObject)top, convention);
        } else {
            // TODO: check JSONArray and report an error
            node = new Node(rootName, convention);
            currentValue = top.toString();
        }
        nodes.push(node);
        event = START_DOCUMENT;
    }
View Full Code Here

            } else {
                nextKey = (String) node.getKeys().next();
                newObj = node.getObject().get(nextKey);
            }
            if (newObj instanceof String) {
                node = new Node(nextKey, convention);
                nodes.push(node);
                currentValue = (String) newObj;
                event = START_ELEMENT;
                return;
            } else if (newObj instanceof JSONArray) {
                JSONArray array = (JSONArray) newObj;
                node = new Node(nextKey, convention);
                node.setArray(array);
                node.setArrayIndex(0);
                nodes.push(node);
                processElement();
                return;
            } else if (newObj instanceof JSONObject) {
                node = new Node(nextKey, (JSONObject) newObj, convention);
                nodes.push(node);
                event = START_ELEMENT;
                return;
            } else {
                node = new Node(nextKey, convention);
                nodes.push(node);
                currentValue = newObj.toString();
                event = START_ELEMENT;
                return;
            }
View Full Code Here

        this.convention = con;
        this.nodes = new FastStack();
        Object top = obj.get(rootName);
        if(top instanceof JSONObject) {
            this.node = new Node(rootName, (JSONObject)top, convention);
        } else {
            // TODO: check JSONArray and report an error
            node = new Node(rootName, convention);
            currentValue = top.toString();
        }
        nodes.push(node);
        event = START_DOCUMENT;
    }
View Full Code Here

                }
            }
        }
        // handle value in nodes with attributes
        if (nodes.size() > 0) {
          Node next = (Node)nodes.peek();
          if (event == START_ELEMENT && next.getName().getLocalPart().equals(valueKey)) {
            event = CHARACTERS;
            node = (Node)nodes.pop();
          }
        }
        return event;
View Full Code Here

            } else {
                nextKey = (String) node.getKeys().next();
                newObj = node.getObject().get(nextKey);
            }
            if (newObj instanceof String) {
                node = new Node(nextKey, convention);
                nodes.push(node);
                currentValue = (String) newObj;
                event = START_ELEMENT;
                return;
            } else if (newObj instanceof JSONArray) {
                JSONArray array = (JSONArray) newObj;
                node = new Node(nextKey, convention);
                node.setArray(array);
                node.setArrayIndex(0);
                nodes.push(node);
                processElement();
                return;
            } else if (newObj instanceof JSONObject) {
                node = new Node(nextKey, (JSONObject) newObj, convention);
                nodes.push(node);
                event = START_ELEMENT;
                return;
            } else {
                node = new Node(nextKey, convention);
                nodes.push(node);
                currentValue = newObj.toString();
                event = START_ELEMENT;
                return;
            }
View Full Code Here

                array.put(newCurrent);
               
                currentNode.put(currentKey, array);
               
                currentNode = newCurrent;
                Node node = new Node(currentNode);
                nodes.push(node);
            } else {
                JSONObject newCurrent = new JSONObject();
               
                if (existing instanceof JSONArray) {
                    ((JSONArray) existing).put(newCurrent);
                } else {
                    currentNode.put(currentKey, newCurrent);
                }
               
                currentNode = newCurrent;
                Node node = new Node(currentNode);
                nodes.push(node);
            }
        } catch (JSONException e) {
            throw new XMLStreamException("Could not write start element!", e);
        }
View Full Code Here

TOP

Related Classes of org.codehaus.jettison.Node

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.