Package helma.objectmodel

Examples of helma.objectmodel.INode


        } else {
            convertedNodes.addElement(node);
            writeTagOpen(node, elementName, propName);

            INode parent = node.getParent();

            if (parent != null) {
                writeReferenceTag(parent, "hop:parent", null);
            }
View Full Code Here


        }

        Enumeration e = node.getSubnodes();

        while (e.hasMoreElements()) {
            INode nextNode = (INode) e.nextElement();

            write(nextNode, "hop:child", null, level);
        }
    }
View Full Code Here

        if (idref != null) {
            // a reference to a node that should have been parsed
            // and lying in our cache of parsed nodes.
            String prototyperef = atts.getValue("prototyperef");
            String key = idref + "-" + prototyperef;
            INode n = (INode) convertedNodes.get(key);

            // if not a reference to a node we already read, try to
            // resolve against the NodeManager.
            if (n == null) {
                n = nmgr.getNode(idref, nmgr.getDbMapping(prototyperef));
View Full Code Here

                    // set the property.
                    int dot = helmaKey.indexOf(".");

                    if (dot > -1) {
                        String prototype = helmaKey.substring(0, dot);
                        INode node = (INode) nodeCache.get(prototype);

                        helmaKey = helmaKey.substring(dot + 1);

                        if ((node != null) && (node.getString(helmaKey) == null)) {
                            node.setString(helmaKey, XmlUtil.getTextContent(childNode));
                        }
                    } else if (helmaNode.getString(helmaKey) == null) {
                        helmaNode.setString(helmaKey, XmlUtil.getTextContent(childNode));

                        if (DEBUG) {
                            debug("childtext-2-property mapping, setting " + helmaKey +
                                  " as string");
                        }
                    }

                    continue;
                }

                // is there a simple child-2-property mapping?
                // (lets the user define to use only one element and make this a property
                // and simply ignore other elements of the same name)
                if ((props != null) && props.containsKey(domKey + "._property")) {
                    helmaKey = props.getProperty(domKey + "._property");

                    // if property is set but without value, read elementname for this mapping:
                    if (helmaKey.equals("")) {
                        helmaKey = childElement.getNodeName().replace(':',
                                                                      defaultSeparator);
                    }

                    if (DEBUG) {
                        debug("child-2-property mapping, helmaKey " + helmaKey +
                              " for domKey " + domKey);
                    }

                    // get the node on which to opererate, depending on the helmaKey
                    // value from the properties file.
                    INode node = helmaNode;
                    int dot = helmaKey.indexOf(".");

                    if (dot > -1) {
                        String prototype = helmaKey.substring(0, dot);

                        if (!prototype.equalsIgnoreCase(node.getPrototype())) {
                            node = (INode) nodeCache.get(prototype);
                        }

                        helmaKey = helmaKey.substring(dot + 1);
                    }

                    if (node == null) {
                        continue;
                    }

                    if (node.getNode(helmaKey) == null) {
                        convert(childElement, node.createNode(helmaKey), nodeCache);

                        if (DEBUG) {
                            debug("read " + childElement.toString() +
                                  node.getNode(helmaKey).toString());
                        }
                    }

                    continue;
                }

                // map it to one of the children-lists
                helma.objectmodel.INode newHelmaNode = null;
                String childrenMapping = props.getProperty(element.getNodeName() +
                                                           "._children");

                // do we need a mapping directly among _children of helmaNode?
                // can either be through property elname._children=_all or elname._children=childname
                if ((childrenMapping != null) &&
                        (childrenMapping.equals("_all") ||
                        childrenMapping.equals(childElement.getNodeName()))) {
                    newHelmaNode = convert(childElement, helmaNode.createNode(null),
                                           nodeCache);
                }

                // in which virtual subnode collection should objects of this type be stored?
                helmaKey = props.getProperty(domKey);

                if ((helmaKey == null) && !sparse) {
                    helmaKey = childElement.getNodeName().replace(':', defaultSeparator);
                }

                if (helmaKey == null) {
                    // we don't map this child element itself since we do
                    // sparse parsing, but there may be something of interest
                    // in the child's attributes and child elements.
                    attributes(childElement, helmaNode, nodeCache);
                    children(childElement, helmaNode, nodeCache);

                    continue;
                }

                // get the node on which to opererate, depending on the helmaKey
                // value from the properties file.
                INode node = helmaNode;
                int dot = helmaKey.indexOf(".");

                if (dot > -1) {
                    String prototype = helmaKey.substring(0, dot);

                    if (!prototype.equalsIgnoreCase(node.getPrototype())) {
                        node = (INode) nodeCache.get(prototype);
                    }

                    helmaKey = helmaKey.substring(dot + 1);
                }

                if (node == null) {
                    continue;
                }

                // try to get the virtual node
                INode worknode = null;

                if ("_children".equals(helmaKey)) {
                    worknode = node;
                } else {
                    worknode = node.getNode(helmaKey);

                    if (worknode == null) {
                        // if virtual node doesn't exist, create it
                        worknode = helmaNode.createNode(helmaKey);
                    }
                }

                if (DEBUG) {
                    debug("mounting child " + childElement.getNodeName() +
                          " at worknode " + worknode.toString());
                }

                // now mount it, possibly re-using the helmaNode that's been created before
                if (newHelmaNode != null) {
                    worknode.addNode(newHelmaNode);
                } else {
                    convert(childElement, worknode.createNode(null), nodeCache);
                }
            }

            // forget about other types (comments etc)
            continue;
View Full Code Here

                // the property should be applied
                int dot = helmaKey.indexOf(".");

                if (dot > -1) {
                    String prototype = helmaKey.substring(0, dot);
                    INode node = (INode) nodeCache.get(prototype);

                    if (node != null) {
                        node.setString(helmaKey.substring(dot + 1), attr.getNodeValue());
                    }
                } else if (helmaNode.getPrototype() != null) {
                    helmaNode.setString(helmaKey, attr.getNodeValue());
                }
            }
View Full Code Here

            node = new Node(null, null, core.getApplication().getWrappedNodeManager());
        }

        try {
            XmlReader reader = new XmlReader(core.app.getWrappedNodeManager());
            INode result = reader.read(new File(file), node);

            return core.getNodeWrapper(result);
        } catch (NoClassDefFoundError e) {
            throw new RuntimeException("Can't load XML parser:" + e);
        } catch (Exception f) {
View Full Code Here

            node = new Node(null, null, core.getApplication().getWrappedNodeManager());
        }

        try {
            XmlReader reader = new XmlReader(core.app.getWrappedNodeManager());
            INode result = reader.read(new StringReader(str), node);

            return core.getNodeWrapper(result);
        } catch (NoClassDefFoundError e) {
            throw new RuntimeException("Can't load XML parser:" + e);
        } catch (Exception f) {
View Full Code Here

                converter = new XmlConverter(conversionRules);
            } else {
                converter = new XmlConverter();
            }

            INode node = new Node(null, null,
                    core.getApplication().getWrappedNodeManager());
            INode result = converter.convert(url, node);

            return core.getNodeWrapper(result);
        } catch (NoClassDefFoundError e) {
            throw new RuntimeException("Can't load dom-capable xml parser.");
        }
View Full Code Here

                converter = new XmlConverter(conversionRules);
            } else {
                converter = new XmlConverter();
            }

            INode node = new Node(null, null, core.getApplication().getWrappedNodeManager());
            INode result = converter.convertFromString(str, node);

            return core.getNodeWrapper(result);
        } catch (NoClassDefFoundError e) {
            throw new RuntimeException("Can't load dom-capable xml parser.");
        }
View Full Code Here

class HopObjectProxy implements SerializationProxy {
    Object ref;
    boolean wrapped = false;

    HopObjectProxy(HopObject obj) {
        INode n = obj.getNode();
        if (n == null) {
            ref = obj.getClassName();
        } else {
            if (n instanceof Node) {
                ref = ((Node) n).getHandle();
View Full Code Here

TOP

Related Classes of helma.objectmodel.INode

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.