Package org.jdom

Examples of org.jdom.Element


       
        if(rootTag.length() == 0){
            ArgCheck.isNotZeroLength(rootTag,CorePlugin.Util.getString("JdomHelper.The_root_tag_name_may_not_be_zero-length_12")); //$NON-NLS-1$
        }
       
        Element root = new Element( rootTag );
        return new Document( root );
    }
View Full Code Here


            ArgCheck.isNotNull(v,CorePlugin.Util.getString("JdomHelper.The_XMLVisitor_reference_may_not_be_null_37")); //$NON-NLS-1$
        }

        LinkedList queue = new LinkedList( parent.getChildren() );
        while( queue.size() != 0 ) {
            Element child = (Element)queue.getFirst();
            v.visit( child );
            queue.addAll( child.getChildren() );
            queue.removeFirst();
        }
    }
View Full Code Here

            ArgCheck.isNotNull(v,CorePlugin.Util.getString("JdomHelper.The_XMLVisitor_reference_may_not_be_null_39")); //$NON-NLS-1$
        }

        List children = parent.getChildren();
        for (int i=0, len=children.size(); i<len; i++) {
            Element child = (Element)children.get( i );
            v.visit( child );
            preOrderTraversal( child, v );
        }
    }
View Full Code Here

            ArgCheck.isNotNull(v,CorePlugin.Util.getString("JdomHelper.The_XMLVisitor_reference_may_not_be_null_41")); //$NON-NLS-1$
        }

        List children = parent.getChildren();
        for (int i=0, len=children.size(); i<len; i++) {
            Element child = (Element)children.get( i );
            postOrderTraversal( child, v );
            v.visit( child );
        }
    }
View Full Code Here

    public static void print( PrintStream stream, Document doc ) {
        if(stream == null){
            ArgCheck.isNotNull(stream,CorePlugin.Util.getString("JdomHelper.The_stream_reference_may_not_be_null_50")); //$NON-NLS-1$
        }
        stream.println(CorePlugin.Util.getString("JdomHelper.JDOM_Document_tree_51")); //$NON-NLS-1$
        Element root = doc.getRootElement();
        print(root,stream,CorePlugin.Util.getString("JdomHelper.___52")); //$NON-NLS-1$
    }
View Full Code Here

        SAXBuilder builder = SAXBuilderHelper.createSAXBuilder(false);
        Document queryDocument = builder.build(queryFile);
        List queryElements = queryDocument.getRootElement().getChildren(TagNames.Elements.QUERY);
        Iterator iter = queryElements.iterator();
        while ( iter.hasNext() ) {
            Element queryElement = (Element) iter.next();
            String queryName = queryElement.getAttributeValue(TagNames.Attributes.NAME);
            if ( queryElement.getChild(TagNames.Elements.EXCEPTION) == null ) {
          String uniqueID = querySetID + "_" + queryName;
         
    List<Element> parmChildren = queryElement.getChildren(TagNames.Elements.SQL);
         
    if (parmChildren == null || parmChildren.isEmpty()) {
              TestLogger.logDebug("=======  Single QueryTest ");
              QuerySQL sql = createQuerySQL(queryElement);
              
              QueryTest q = new QueryTest(queryScenarioID, uniqueID, querySetID, new QuerySQL[] {sql}, false);
              queries.add(q);
          } else {
              TestLogger.logDebug("=======  QueryTest has multiple sql statements");
             QuerySQL[] querysql = new QuerySQL[parmChildren.size()];
            int c = 0;
           
            final Iterator<Element> sqliter = parmChildren.iterator();
            while ( sqliter.hasNext() ) {
              final Element sqlElement = (Element) sqliter.next();
              QuerySQL sql = createQuerySQL(sqlElement);
              querysql[c] = sql;
              c++; 
            }
            QueryTest q = new QueryTest(queryScenarioID, uniqueID, querySetID, querysql, false);
            queries.add(q);
                  
           
            
          }
//               queryMap.put(queryName, query);
            } else {
                Element exceptionElement = queryElement.getChild(TagNames.Elements.EXCEPTION);
                String exceptionType = exceptionElement.getChild(TagNames.Elements.CLASS).getTextTrim();
               
                String uniqueID = querySetID + "_" + queryName;
                QuerySQL sql = new QuerySQL(exceptionType, null);
               
                QueryTest q = new QueryTest(queryScenarioID, uniqueID, querySetID, new QuerySQL[] {sql}, true);
View Full Code Here

 
  Object[] parms = new Object[parmChildren.size()];
  int i = 0;
  final Iterator<Element> iter = parmChildren.iterator();
  while ( iter.hasNext() ) {
    final Element parmElement = (Element) iter.next();
    try {
        Object parm = createParmType(parmElement);
        parms[i] = parm;
        i++;
    } catch (JDOMException e) {
View Full Code Here

        final Document resultsDocument = builder.build(resultsFile);
        final String query = resultsDocument.getRootElement().getChildText(TagNames.Elements.QUERY);
        final List resultElements = resultsDocument.getRootElement().getChildren(TagNames.Elements.QUERY_RESULTS);
        final Iterator iter = resultElements.iterator();
        while ( iter.hasNext() ) {
            final Element resultElement = (Element) iter.next();
            final String resultName = resultElement.getAttributeValue(TagNames.Attributes.NAME);
            queryResults = consumeMsg(new QueryResults(), resultElement);
            if ( queryResults.getFieldCount() != 0 ) {
                //
                // We've got a ResultSet
                //
                expectedResults = new ResultsHolder( TagNames.Elements.QUERY_RESULTS );
                expectedResults.setQueryID( resultName );
                expectedResults.setQuery(query);
                expectedResults.setIdentifiers( queryResults.getFieldIdents() );
                expectedResults.setTypes( queryResults.getTypes() );
                if ( queryResults.getRecordCount() > 0 ) {
                    expectedResults.setRows(queryResults.getRecords());
                }
            } else {
                //
                // We've got an exception
                //
                expectedResults = new ResultsHolder( TagNames.Elements.EXCEPTION );
                expectedResults.setQueryID( resultName );
                expectedResults.setQuery(query);

                final Element exceptionElement = resultElement.getChild(TagNames.Elements.EXCEPTION);
                if ( exceptionElement != null ) {
                    expectedResults.setExceptionClassName(exceptionElement.getChild(TagNames.Elements.CLASS).getTextTrim());
                    String msg = exceptionElement.getChild(TagNames.Elements.MESSAGE).getTextTrim();  
                    expectedResults.setExceptionMsg(StringUtil.removeChars(msg, new char[] {'\r'}));
                }
            }
        }
        return expectedResults;
View Full Code Here

        SAXBuilder builder = SAXBuilderHelper.createSAXBuilder(false);
        Document resultsDocument = builder.build(resultsFile);
        List resultElements = resultsDocument.getRootElement().getChildren(TagNames.Elements.QUERY_RESULTS);
        Iterator iter = resultElements.iterator();
        while ( iter.hasNext() ) {
            Element resultElement = (Element) iter.next();
            if ( resultElement.getChild(TagNames.Elements.SELECT) == null ) {
                // We've got an exception
                Element exceptionElement = resultElement.getChild(TagNames.Elements.EXCEPTION);
                if ( exceptionElement != null ) {
                    // ---------------------------------
                    // Add the ExceptionType element ...
                    // ---------------------------------
                    Element typeElement = new Element(TagNames.Elements.EXCEPTION_TYPE);
                    typeElement.setText(exceptionElement.getChild(TagNames.Elements.EXCEPTION_TYPE).getTextTrim());
                    parent.addContent(typeElement);

                    // ---------------------------
                    // Add the Message element ...
                    // ---------------------------
                    Element messageElement = new Element(TagNames.Elements.MESSAGE);   
                    String msg = exceptionElement.getChild(TagNames.Elements.MESSAGE).getTextTrim();  
                   
                    messageElement.setText(StringUtil.removeChars(msg, new char[] {'\r'}));
                    parent.addContent(messageElement);

                    // -------------------------
                    // Add the Class element ...
                    // -------------------------
                    Element classElement = new Element(TagNames.Elements.CLASS);
                    classElement.setText(exceptionElement.getChild(TagNames.Elements.CLASS).getTextTrim());
                    parent.addContent(classElement);
                }
            } else {
                // We've got results

                // -------------------------------
                // Read the SELECT elements
                // -------------------------------
                Element selectElement = resultElement.getChild(TagNames.Elements.SELECT);
                resultElement.removeChild(TagNames.Elements.SELECT);
                parent.addContent(selectElement);

                // -------------------------------
                // Read the TABLE of data
                // -------------------------------
                Element tableElement = resultElement.getChild(TagNames.Elements.TABLE);
                resultElement.removeChild(TagNames.Elements.TABLE);
                parent.addContent(tableElement);
            }
        }
        return parent;
View Full Code Here

        String className = ex.getClass().getName();
        int index = className.lastIndexOf('.');
        if ( index != -1 && (++index) < className.length() ) {
            className = className.substring(index);
        }
        Element typeElement = new Element(TagNames.Elements.EXCEPTION_TYPE);
        typeElement.setText(className);
        exceptionElement.addContent(typeElement);

        // ---------------------------
        // Add the Message element ...
        // ---------------------------
        Element messageElement = new Element(TagNames.Elements.MESSAGE);
        messageElement.setText(StringUtil.removeChars(ex.getMessage(), new char[] {'\r'}));    
           
        exceptionElement.addContent(messageElement);

        // -------------------------
        // Add the Class element ...
        // -------------------------
        Element classElement = new Element(TagNames.Elements.CLASS);
        classElement.setText(ex.getClass().getName());
        exceptionElement.addContent(classElement);

        return exceptionElement;
    }
View Full Code Here

TOP

Related Classes of org.jdom.Element

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.