Package org.jdom

Examples of org.jdom.Element


    private Element produceMsg(Short object, Element parent) throws JDOMException {

        // ----------------------
        // Create the Long element ...
        // ----------------------
        Element shortElement = new Element(TagNames.Elements.SHORT);
        shortElement.setText(object.toString());
        if ( parent != null ) {
            shortElement = parent.addContent(shortElement);
        }

        return shortElement;
View Full Code Here


     * @exception JDOMException if there is an error producing the message.
     */
    private Element produceMsg(Throwable object, Element parent) throws JDOMException {

        Throwable exception = object;
        Element exceptionElement = null;

        // --------------------------------
        // Create the Exception element ...
        // --------------------------------
        exceptionElement = new Element(TagNames.Elements.EXCEPTION);

        // ---------------------------------
        // Add the ExceptionType element ...
        // ---------------------------------
        String className = exception.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(exception.getMessage(), new char[] {'\r'}));
        
        exceptionElement.addContent(messageElement);

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

        if ( parent != null ) {
            exceptionElement = parent.addContent(exceptionElement);
        }
View Full Code Here

  try {
      XMLQueryVisitationStrategy jstrat = new XMLQueryVisitationStrategy();

      // Create root JDOM element
      Element rootElement = new Element(TagNames.Elements.ROOT_ELEMENT);

      // Create Query element
      Element queryElement = new Element(TagNames.Elements.QUERY);
      queryElement.addContent(new CDATA(query));
      rootElement.addContent(queryElement);

      // create a result attribute for the queryID
      Attribute resultsIDAttribute = new Attribute(
        TagNames.Attributes.NAME, queryID);

      if (result != null) {
    // produce a JDOM element from the results object
    Element resultsElement = jstrat.produceResults(result);
    // set the resultsIDAttribute on the results element
    resultsElement.setAttribute(resultsIDAttribute);
    // add the results elements to the root element
    rootElement.addContent(resultsElement);
    // debug:
    // System.out.println("\n Result: " + printResultSet(result));
      } else {
    // create a JDOM element from the exception object with the
    // results tag
    Element exceptionElement = new Element(
      TagNames.Elements.QUERY_RESULTS);
    // produce xml for the actualException and this to the
    // exceptionElement
    if (ex != null) {
        exceptionElement.addContent(jstrat.produceMsg(ex, null));
    }
    // set the resultsIDAttribute on the exception element
    exceptionElement.setAttribute(resultsIDAttribute);
    // add the results elements to the root element
    rootElement.addContent(exceptionElement);

      }
View Full Code Here

  try {
      XMLQueryVisitationStrategy jstrat = new XMLQueryVisitationStrategy();

      // Create root JDOM element
      Element rootElement = new Element(TagNames.Elements.ROOT_ELEMENT);

      // create a JDOM element for the results
      Element resultElement = new Element(TagNames.Elements.QUERY_RESULTS);
      // set the queryIDAttr on the exception element
      resultElement.setAttribute(new Attribute(TagNames.Attributes.NAME,
        queryID));
      // set the querySQLAttr on the exception element
      resultElement.setAttribute(new Attribute(TagNames.Attributes.VALUE,
        sql));

      // ---------------------
      // Actual Exception
      // ---------------------
      // create a JDOM element from the actual exception object
      // produce xml for the actualException and this to the
      // exceptionElement
      if (ex != null) {
    Element actualExceptionElement = new Element(
      TagNames.Elements.ACTUAL_EXCEPTION);

    actualExceptionElement = XMLQueryVisitationStrategy
      .jdomException(ex, actualExceptionElement);
    resultElement.addContent(actualExceptionElement);
      }

      if (actualResult != null) {
    // ------------------------------
    // Got a ResultSet from server
    // error was in comparing results
    // ------------------------------

    // --------------------------
    // Actual Result - ResultSet
    // --------------------------
    // produce a JDOM element from the actual results object
    Element actualResultsElement = new Element(
      TagNames.Elements.ACTUAL_QUERY_RESULTS);
    actualResultsElement = jstrat.produceMsg(actualResult,
      actualResultsElement);

    // add the results elements to the root element
    resultElement.addContent(actualResultsElement);

    // ---------------------
    // Expected Results - ...
    // ---------------------
    // produce xml for the expected results
    // Get expected results
    Element expectedResult = new Element("bogus"); //$NON-NLS-1$
    expectedResult = jstrat.parseXMLResultsFile(expectedResultFile,
      expectedResult);
    if (expectedResult.getChild(TagNames.Elements.SELECT) != null) {
        //----------------------------------------------------------
        // -
        // Expected result was a ResultSet set element name to
        // reflect
        //----------------------------------------------------------
        // -
        expectedResult
          .setName(TagNames.Elements.EXPECTED_QUERY_RESULTS);
    } else {
        //----------------------------------------------------------
        // --
        // Expected result was an exception set element name to
        // reflect
        //----------------------------------------------------------
        // --
        expectedResult
          .setName(TagNames.Elements.EXPECTED_EXCEPTION);
    }
    resultElement.addContent(expectedResult);
      } else {

    // ---------------------
    // Expected Results - ...
    // ---------------------
    // produce xml for the expected results
    // Get expected results
    Element expectedResult = new Element("bogus"); //$NON-NLS-1$
    expectedResult = jstrat.parseXMLResultsFile(expectedResultFile,
      expectedResult);
    if (expectedResult.getChild(TagNames.Elements.SELECT) != null) {
        //----------------------------------------------------------
        // -
        // Expected result was a ResultSet set element name to
        // reflect
        //----------------------------------------------------------
        // -
        expectedResult
          .setName(TagNames.Elements.EXPECTED_QUERY_RESULTS);
    } else {
        //----------------------------------------------------------
        // --
        // Expected result was an exception set element name to
        // reflect
        //----------------------------------------------------------
        // --
        expectedResult
          .setName(TagNames.Elements.EXPECTED_EXCEPTION);
    }
    resultElement.addContent(expectedResult);
      }
View Full Code Here

   * @return Element the layout element associate to the field passed in.
   * @param eField Element the Field XML Element contained within the EnterpriseObjects documents
   * @param name String the layout name contained within the Layout Element in the EnterpriseObjects document
   */
  protected final Element getFieldLayout(Element eField, String name) {
    Element eLayouts = eField.getChild("Layouts");
    if (eLayouts != null) {
      java.util.List lLayouts = eLayouts.getChildren("Layout");
      for (int i=0; i<lLayouts.size(); i++) {
        Element eLayout = (Element)lLayouts.get(i);
        Attribute aName = eLayout.getAttribute("name");
        if (aName != null) {
          String layoutName = aName.getValue();
          logger.debug("Layout [" + i + "] name is: " + layoutName);
          if (layoutName.equalsIgnoreCase(name)) {
            return eLayout;
View Full Code Here

  private java.util.List getChildDefinitions(Element root) throws EnterpriseLayoutException {
    ArrayList objDefs = new ArrayList();
    java.util.List eChildren = root.getChildren("ObjectDefinition");
    for (int j=0; j<eChildren.size(); j++) {
      Element eChild = (Element)eChildren.get(j);
      objDefs.add(eChild);
    }
   
    Element eIncludeList = root.getChild("IncludeList");
    if (eIncludeList != null) {
      java.util.List eDocUriList = eIncludeList.getChildren();
      XmlDocumentReader xmlReader = new XmlDocumentReader();
      for (int i=0; i<eDocUriList.size(); i++) {
        Element eDocUri = (Element)eDocUriList.get(i);
        String docUri = eDocUri.getText();
        try {
          Document includedDoc = xmlReader.initializeDocument(docUri,false);
          java.util.List includedObjDefs = getChildDefinitions(includedDoc.getRootElement());
          for (int h=0; h<includedObjDefs.size(); h++) {
            objDefs.add((Element)includedObjDefs.get(h));
View Full Code Here

  }
  private void buildLayoutDocument(Document inDoc) throws EnterpriseLayoutException {

    // recursively parse and build all 'included' enterprise object document references.
   
    Element inDocRoot = inDoc.getRootElement();
    java.util.List objDefs = getChildDefinitions(inDocRoot);
   
    for (int j=0; j<objDefs.size(); j++) {
      Element eChild = (Element)objDefs.get(j);
      String childName = eChild.getAttribute("name").getValue();
      if (childExists(childName, inDocRoot) == false) {
        inDocRoot.addContent((Element)eChild.clone());
      }           
    }
  }
View Full Code Here

  }

  private boolean childExists(String childName, Element rootElement) {
    java.util.List eChildren = rootElement.getChildren("ObjectDefinition");
    for (int j=0; j<eChildren.size(); j++) {
      Element eChild = (Element)eChildren.get(j);
      String existingChildName = eChild.getAttribute("name").getValue();
      if (childName.equals(existingChildName)) {
        return true;
      }           
    }
    return false;
View Full Code Here

    // to this by using the layoutManagerName

    buildLayoutDocument(layoutDoc);

    setLayoutManagerName(layoutManagerName);
    Element rootElement = layoutDoc.getRootElement();
    logger.debug("RootElement is: " + rootElement.getName());

    Element layoutElement = rootElement;

    setLayoutRoot(layoutElement);
  }
View Full Code Here

        logger.info("  " + e.getName() + " Name: " + sname);
      }
    }
    */

    Element layoutElement = xmlLoc.getElementByAttributeNameValue(startingElement,"name",name);
    if (layoutElement != null) {
      logger.debug("Found layout manager " + name + " Element name: " + layoutElement.getName());
    }
    else {
      // Need to throw an exception here!
      throw new EnterpriseLayoutException("Could not find layout manager named " + name);
    }
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.