Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/aendvari/cerberus/component/descriptor/parser/DescriptorParser.java


1   /*
2    * DescriptorParser.java
3    *
4    * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5    *
6    * See the file LICENSE for terms of use.
7    *
8    */
9   
10  package com.aendvari.cerberus.component.descriptor.parser;
11  
12  import java.io.InputStream;
13  import java.io.IOException;
14  
15  import java.util.ArrayList;
16  import java.util.Collection;
17  
18  import com.aendvari.common.model.*;
19  import com.aendvari.cerberus.component.descriptor.*;
20  
21  /**
22   * <p>Provides a base parser for component descriptor parsers. Several utility
23   * methods are provided to parse typical objects.</p>
24   *
25   * @author  Trevor Milne
26   *
27   */
28  
29  public class DescriptorParser
30  {
31    /* Constants. */
32  
33  
34    /** Constants for descriptor element names. */
35    private interface NodeNames
36    {
37      public static String Attribute      = "attribute";
38      public static String Literal      = "literal";
39    }
40  
41  
42    /* Constructors. */
43  
44  
45    /**
46     * Constructs a <code>DescriptorParser</code> instance.
47     *
48     */
49  
50    public DescriptorParser()
51    {
52    }
53  
54  
55    /* Parsing. */
56  
57  
58    /**
59     * Parses a multi-part value.
60     *
61     * @param    objectNode          The <code>Node</code> containing the property section.
62     * @param    value            The {@link MultiPartValue} to store the information.
63     *
64     */
65  
66    protected void parseMultiPartValue(ModelNode objectNode, MultiPartValue value)
67    {
68      ModelNode node = objectNode.getFirstChild();
69  
70      while (node != null)
71      {
72        String nodeName = node.getNodeName();
73  
74        // process node types
75        if (nodeName.equals(NodeNames.Attribute))
76        {
77          value.addAttribute(node.getNodeValue());
78        }
79        else
80        if (nodeName.equals(NodeNames.Literal))
81        {
82          value.addLiteral(node.getNodeValue());
83        }
84  
85        // get next child node
86        node = node.getNextSibling();
87      }
88    }
89  }
90