public static void addToFlex(String name) {
    SAXReader reader = new SAXReader();
    Document document;
    try {
      document = reader.read(new File(FLEX_CONFIG));
      Element flex = document.getRootElement();
      // Flex-------------------------------------------------------------
      Element destination = flex.addElement("destination");
      destination.addAttribute("id", name);
      Element properties = destination.addElement("properties");
      Element factory = properties.addElement("factory");
      Element source = properties.addElement("source");
      factory.addText("springFactory");
      source.addText(Tools.firstLowcase(name));

      // 更新保存----------------------------------------------------
      XMLWriter writer = new XMLWriter(new FileWriter(FLEX_CONFIG));
      writer.write(document);
      writer.close();

    } catch (DocumentException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  /**
   * 请求缩略图数据的报文:requestContacts(String)
   *
   * @return
   */
  public String generateDocument() {

    String sysdate = FormatTime.formatDate("yyyyMMddHHmmssSSS");
    sysdate = sysdate.concat(FormatTime.randomInt(3));
    Document document = DocumentHelper.createDocument();
    Element msgElement = document.addElement("msg");
    Element routerElement = msgElement.addElement("router");
    Element msgIdElement = routerElement.addElement("msgId");
    msgIdElement.setText(sysdate);
    Element fromElement = routerElement.addElement("from");
    fromElement.setText("微信");
    Element toElement = routerElement.addElement("to");
    toElement.setText("Service");
    Element timeElement = routerElement.addElement("time");
    timeElement.addText("");
    Element sevicenameElement = routerElement.addElement("serviceName");
    sevicenameElement.addText("PICTURE");
    Element dataElement = msgElement.addElement("data");
    Element userIdElement = dataElement.addElement("userId");
    userIdElement.setText("666666");
    Element requestMethodElement = dataElement.addElement("requestMethod");
    requestMethodElement.addText("portraitThumbnail");
    Element lastModifyTimeElement = dataElement.addElement("lastModifyTime");
    lastModifyTimeElement.addText("20151001230842");
    //			lastModifyTimeElement.addText(FormatTime.formatDate("yyyyMMddHHmmss"));
    String requestContacts = document.asXML();
    //			System.out.println(requestContacts);
    return requestContacts;
  }
Beispiel #3
0
 @Override
 protected Element toXmlElement() {
   Element findElement = DocumentHelper.createElement("Find");
   Element methodElement = findElement.addElement("method");
   Element valueElement = findElement.addElement("value");
   methodElement.addText(methodMap.get(method));
   valueElement.addText(value);
   return findElement;
 }
Beispiel #4
0
  private static Element matrix4d2Transform(Matrix4d matrix4d) {
    Element transform = new BaseElement("Transform");

    Element m0 = new BaseElement("m0");
    m0.addText(
        matrix4d.getM00()
            + " "
            + matrix4d.getM01()
            + " "
            + matrix4d.getM02()
            + " "
            + matrix4d.getM03()
            + ".");
    transform.add(m0);

    Element m1 = new BaseElement("m1");
    m1.addText(
        matrix4d.getM10()
            + " "
            + matrix4d.getM11()
            + " "
            + matrix4d.getM12()
            + " "
            + matrix4d.getM13()
            + ".");
    transform.add(m1);

    Element m2 = new BaseElement("m2");
    m2.addText(
        matrix4d.getM20()
            + " "
            + matrix4d.getM21()
            + " "
            + matrix4d.getM22()
            + " "
            + matrix4d.getM23()
            + ".");
    transform.add(m2);

    Element m3 = new BaseElement("m3");
    m3.addText(
        matrix4d.getM30()
            + " "
            + matrix4d.getM31()
            + " "
            + matrix4d.getM32()
            + " "
            + matrix4d.getM33()
            + ".");
    transform.add(m3);

    return transform;
  }
  protected void addRootRecordInfo(Element recordInfoEl) {
    Date now = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

    String nowStr = sdf.format(now);
    Element creationDate =
        recordInfoEl.addElement(new QName("recordCreationDate", Namespaces.mods));
    creationDate.addAttribute("encoding", "iso8601");
    creationDate.addText(nowStr);
    Element changeDate = recordInfoEl.addElement(new QName("recordChangeDate", Namespaces.mods));
    changeDate.addAttribute("encoding", "iso8601");
    changeDate.addText(nowStr);
  }
 private Element addElement(Element parent, String name, String text) {
   Element element = parent.addElement(name);
   if (text != null) {
     element.addText(text);
   }
   return element;
 }
  protected void addRootPlace(Element originInfoEl) {
    ModsTypeClient mods = getFirstMods();
    PlaceTypeClient placeClient = null;
    if (mods != null
        && mods.getOriginInfo() != null
        && mods.getOriginInfo().size() > 0
        && mods.getOriginInfo().get(0).getPlace() != null
        && mods.getOriginInfo().get(0).getPlace().size() > 0)
      placeClient = mods.getOriginInfo().get(0).getPlace().get(0);

    if (placeClient != null
        && placeClient.getPlaceTerm() != null
        && placeClient.getPlaceTerm().size() > 0) {
      String authority = placeClient.getPlaceTerm().get(0).getAuthority().value();
      String type = placeClient.getPlaceTerm().get(0).getType().value();
      String place = placeClient.getPlaceTerm().get(0).getValue();
      if (authority != null && type != null && place != null) {
        Element placeEl = originInfoEl.addElement(new QName("place", Namespaces.mods));
        Element placeTermEl = placeEl.addElement(new QName("placeTerm", Namespaces.mods));
        placeTermEl.addAttribute("type", type);
        placeTermEl.addAttribute("authority", authority);
        placeTermEl.addText(place);
      }
    }
  }
Beispiel #8
0
 @Override
 protected Element toXmlElement() {
   Element classElement = DocumentHelper.createElement("Class");
   Element pathElement = classElement.addElement("filePath");
   pathElement.addText(classFilePath);
   return classElement;
 }
Beispiel #9
0
  public static String setGraphXml(String sourceNode, Map<String, String> map, String xml)
      throws IOException {
    Document doc = Dom4jUtil.loadXml(xml);
    Element root = doc.getRootElement();

    Element node = (Element) root.selectSingleNode("//bg:Gateway[@id='" + sourceNode + "']");
    Element portsEl = node.element("ports");
    List portList = portsEl.elements();

    for (int i = 0; i < portList.size(); i++) {
      Element portEl = (Element) portList.get(i);
      if ((portEl.attribute("x") != null) || (portEl.attribute("y") != null)) {
        String id = portEl.attributeValue("id");
        Element outNode =
            (Element) root.selectSingleNode("//bg:SequenceFlow[@startPort='" + id + "']");
        if (outNode != null) {
          String outPort = outNode.attributeValue("endPort");
          Element tmpNode = (Element) root.selectSingleNode("//ciied:Port[@id='" + outPort + "']");
          Element taskNode = tmpNode.getParent().getParent();
          String taskId = taskNode.attributeValue("id");

          Element conditionEl = outNode.element("condition");
          if (conditionEl != null) {
            outNode.remove(conditionEl);
          }
          if (map.containsKey(taskId)) {
            String condition = (String) map.get(taskId);
            Element elAdd = outNode.addElement("condition");
            elAdd.addText(condition);
          }
        }
      }
    }
    return doc.asXML();
  }
 private void makeRemoteRequest() throws InterruptedException {
   request.setTo(new JID(node.split("/")[2]).getDomain());
   Element actor =
       request.getElement().element("pubsub").addElement("actor", JabberPubsub.NS_BUDDYCLOUD);
   actor.addText(request.getFrom().toBareJID());
   outQueue.put(request);
 }
Beispiel #11
0
 public void CreateHeader(Element root) {
   Element Header = root.addElement("soap:Header");
   Element Security = Header.addElement("wsse:Security");
   Security.addAttribute("soap:actor", "http://smev.gosuslugi.ru/actors/smev");
   Element BinarySecurityToken = Security.addElement("wsse:BinarySecurityToken");
   BinarySecurityToken.addAttribute(
       "EncodingType",
       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
   BinarySecurityToken.addAttribute(
       "ValueType",
       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");
   BinarySecurityToken.addAttribute("wsu:Id", "CertId-1");
   BinarySecurityToken.addAttribute(
       "xmlns:wsu",
       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
   BinarySecurityToken.addText(Cert);
   Element Signature = Security.addElement("ds:Signature");
   Signature.addAttribute("Id", "Signature-1");
   Element SignedInfo = Signature.addElement("ds:SignedInfo");
   Element CanonicalizationMethod = SignedInfo.addElement("ds:CanonicalizationMethod");
   CanonicalizationMethod.addAttribute("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#");
   Element SignatureMethod = SignedInfo.addElement("ds:SignatureMethod");
   SignatureMethod.addAttribute(
       "Algorithm", "http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411");
   Element Reference = SignedInfo.addElement("ds:Reference");
   Reference.addAttribute("URI", "#body");
   Element Transforms = Reference.addElement("ds:Transforms");
   Element Transform = Transforms.addElement("ds:Transform");
   Element DigestMethod = Reference.addElement("ds:DigestMethod");
   Element DigestValue = Reference.addElement("ds:DigestValue");
   DigestValue.addText(Hash);
   Element SignatureValue = Signature.addElement("ds:SignatureValue");
   SignatureValue.addText(Sign);
   Element KeyInfo = Signature.addElement("ds:KeyInfo");
   KeyInfo.addAttribute("Id", "KeyId-1");
   Element SecurityTokenReference = KeyInfo.addElement("wsse:SecurityTokenReference");
   SecurityTokenReference.addAttribute("wsu:Id", "STRId-1");
   SecurityTokenReference.addAttribute(
       "xmlns:wsu",
       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
   Element Reference1 = SecurityTokenReference.addElement("wsse:Reference");
   Reference1.addAttribute("URI", "#CertId-1");
   Reference1.addAttribute(
       "ValueType",
       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");
 }
 protected void addRootPublisher(Element originInfoEl) {
   if (getBundle() != null && getBundle().getMarc() != null) {
     String name = getBundle().getMarc().getPublisher();
     if (isNotNullOrEmpty(name)) {
       Element publisher = originInfoEl.addElement(new QName("publisher", Namespaces.mods));
       publisher.addText(name);
     }
   }
 }
 protected void decorateDCStream() {
   Element rootElement = DocumentHelper.createElement(new QName("dc", Namespaces.oai_dc));
   rootElement.add(Namespaces.dc);
   rootElement.add(Namespaces.xsi);
   Element title = rootElement.addElement(new QName("title", Namespaces.dc));
   title.addText(getLabel());
   Element identifier = rootElement.addElement(new QName("identifier", Namespaces.dc));
   identifier.setText(getPid());
   Element type = rootElement.addElement(new QName("type", Namespaces.dc));
   type.addText(
       "model:"
           + getModel().getValue().substring(0, 1)
           + getModel().getValue().substring(1).toLowerCase());
   Element rights = rootElement.addElement(new QName("rights", Namespaces.dc));
   rights.addText("policy:" + getPolicy().toString().toLowerCase());
   appendDatastream(DATASTREAM_CONTROLGROUP.X, DATASTREAM_ID.DC, rootElement, null, null);
   dcXmlContent = rootElement.getDocument();
 }
 protected void addRootTopic(Element modsRootEl) {
   if (getBundle() != null && getBundle().getMarc() != null) {
     String topic = getBundle().getMarc().getTopic();
     if (topic != null) {
       Element subjectEl = modsRootEl.addElement(new QName("subject", Namespaces.mods));
       Element topicEl = subjectEl.addElement(new QName("topic", Namespaces.mods));
       topicEl.addText(topic);
     }
   }
 }
  /**
   * Create an XML representation of the Annotated Class, passing a Document to which the XML should
   * be added.
   *
   * @param doc generally an emtpy Document
   * @return
   */
  public Element toXML(Document doc) {
    Element root = doc.addElement("annotatedclass");
    Element clazz = root.addElement("name");
    clazz.addText(this.getClassName());
    Element mapping = root.addElement("mapping");
    mapping.addText(this.getPath());
    if (!this.getAction().isEmpty()) {
      Element action = root.addElement("action");
      action.addText(this.getAction());
    }
    if (!this.listOfMethods.isEmpty()) {
      Element methods = root.addElement("methods");

      for (AnnotatedMethod am : listOfMethods) {

        methods.add(am.toXML());
      }
    }
    return root;
  }
  private void getAddStrutsElemant(String filePath, String nodexPath) throws Exception {

    Document document = getPath(filePath, "utf-8");
    Element element = document.getRootElement();
    Element nextElement = element.element("package");
    Element newElement = nextElement.addElement("action");
    newElement.addComment("系统自动创建");
    newElement.addAttribute("name", "test");
    newElement.addAttribute("class", "");
    newElement.addAttribute("method", "");
    newElement.addText("hello");
  }
 protected void addRootUdcOrDdc(Element modsRootEl) {
   if (getBundle() != null && getBundle().getMarc() != null) {
     if (getBundle().getMarc().getUdcs() == null) {
       return;
     }
     List<String> udcs = getBundle().getMarc().getUdcs();
     for (String udc : udcs) {
       Element classificationEl =
           modsRootEl.addElement(new QName("classification", Namespaces.mods));
       classificationEl.addAttribute("authority", "udc");
       classificationEl.addText(udc);
     }
   }
 }
 private void makeRemoteRequests(IQ request, Set<String> remoteDomains) throws Exception {
   for (String remoteDomain : remoteDomains) {
     IQ remoteRequest = request.createCopy();
     remoteRequest.getElement().addAttribute("remote-server-discover", "false");
     remoteRequest.setTo(remoteDomain);
     Element actor =
         remoteRequest
             .getElement()
             .element("query")
             .element("remove")
             .addElement("actor", Buddycloud.NS);
     actor.addText(request.getFrom().toBareJID());
     outQueue.put(remoteRequest);
   }
 }
Beispiel #19
0
  /**
   * Write the package.xml file to an {@link XMLWriter}.
   *
   * @param wr the writer to write to
   * @throws IOException when an error occurs during streaming operation
   * @since 2.3M2
   */
  public void toXML(XMLWriter wr) throws IOException {
    Element docel = new DOMElement("package");
    wr.writeOpen(docel);

    Element elInfos = new DOMElement("infos");
    wr.write(elInfos);

    Element el = new DOMElement("name");
    el.addText(this.name);
    wr.write(el);

    el = new DOMElement("description");
    el.addText(this.description);
    wr.write(el);

    el = new DOMElement("licence");
    el.addText(this.licence);
    wr.write(el);

    el = new DOMElement("author");
    el.addText(this.authorName);
    wr.write(el);

    el = new DOMElement("version");
    el.addText(this.version);
    wr.write(el);

    el = new DOMElement("backupPack");
    el.addText(new Boolean(this.backupPack).toString());
    wr.write(el);

    el = new DOMElement("preserveVersion");
    el.addText(new Boolean(this.preserveVersion).toString());
    wr.write(el);

    Element elfiles = new DOMElement("files");
    wr.writeOpen(elfiles);

    for (DocumentInfo docInfo : this.files) {
      Element elfile = new DOMElement("file");
      elfile.addAttribute("defaultAction", String.valueOf(docInfo.getAction()));
      elfile.addAttribute("language", String.valueOf(docInfo.getLanguage()));
      elfile.addText(docInfo.getFullName());
      wr.write(elfile);
    }
  }
Beispiel #20
0
  public Element toXML() {
    Element cel = new DOMElement("class");

    Element el = new DOMElement("name");
    el.addText((getName() == null) ? "" : getName());
    cel.add(el);

    el = new DOMElement("customClass");
    el.addText((getCustomClass() == null) ? "" : getCustomClass());
    cel.add(el);

    el = new DOMElement("customMapping");
    el.addText((getCustomMapping() == null) ? "" : getCustomMapping());
    cel.add(el);

    el = new DOMElement("defaultViewSheet");
    el.addText((getDefaultViewSheet() == null) ? "" : getDefaultViewSheet());
    cel.add(el);

    el = new DOMElement("defaultEditSheet");
    el.addText((getDefaultEditSheet() == null) ? "" : getDefaultEditSheet());
    cel.add(el);

    el = new DOMElement("defaultWeb");
    el.addText((getDefaultWeb() == null) ? "" : getDefaultWeb());
    cel.add(el);

    el = new DOMElement("nameField");
    el.addText((getNameField() == null) ? "" : getNameField());
    cel.add(el);

    el = new DOMElement("validationScript");
    el.addText((getValidationScript() == null) ? "" : getValidationScript());
    cel.add(el);

    // Iterate over values sorted by field name so that the values are
    // exported to XML in a consistent order.
    Iterator it = getSortedIterator();
    while (it.hasNext()) {
      PropertyClass bprop = (PropertyClass) it.next();
      cel.add(bprop.toXML());
    }
    return cel;
  }
  @Override
  public InputStream getMetadataStream(String site, String path) {
    PersistenceManagerService persistenceManagerService =
        _servicesManager.getService(PersistenceManagerService.class);
    NodeRef nodeRef =
        persistenceManagerService.getNodeRef(
            SITE_REPO_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site), path);
    Map<QName, Serializable> contentProperties = persistenceManagerService.getProperties(nodeRef);
    Document metadataDoc = DocumentHelper.createDocument();
    Element root = metadataDoc.addElement("metadata");
    for (Map.Entry<QName, Serializable> property : contentProperties.entrySet()) {
      Element elem = root.addElement(property.getKey().getLocalName());
      elem.addText(String.valueOf(property.getValue()));
    }

    return IOUtils.toInputStream(metadataDoc.asXML());
  }
  protected void addRootLanguage(Element modsRootEl) {
    ModsTypeClient mods = getFirstMods();
    if (mods != null
        && mods.getLanguage() != null
        && mods.getLanguage().size() > 0
        && mods.getLanguage().get(0).getLanguageTerm() != null
        && mods.getLanguage().get(0).getLanguageTerm().size() > 0
        && mods.getLanguage().get(0).getLanguageTerm().get(0) != null
        && isNotNullOrEmpty(mods.getLanguage().get(0).getLanguageTerm().get(0).getValue())) {

      Element languageEl = modsRootEl.addElement(new QName("language", Namespaces.mods));
      Element languageTerm = languageEl.addElement(new QName("languageTerm", Namespaces.mods));
      languageTerm.addAttribute("type", "code");
      languageTerm.addAttribute("authority", "iso639-2b");
      languageTerm.addText(mods.getLanguage().get(0).getLanguageTerm().get(0).getValue());
    }
  }
  protected void addRootPhysicalLocation(Element locationEl, boolean doDetach) {
    if (getBundle() != null && getBundle().getMarc() != null) {
      String location = getBundle().getMarc().getLocation();

      if (location != null) {
        //            Element shelfLocatorEl = (Element)
        // shelfLocatorXpath.selectSingleNode(locationEl);
        //            String shelfLocatorStr = "";
        //            if (shelfLocatorEl != null) {
        //                shelfLocatorStr = shelfLocatorEl.getTextTrim();
        //                if (doDetach) shelfLocatorEl.detach();
        //            }
        Element physicalLocationEl =
            locationEl.addElement(new QName("physicalLocation", Namespaces.mods));
        physicalLocationEl.addText(location);
        //            shelfLocatorEl = locationEl.addElement(new QName("shelfLocator",
        // Namespaces.mods));
        //            shelfLocatorEl.addText(shelfLocatorStr);
      }
    }
  }
Beispiel #24
0
  /**
   * This will take an attribute name and it's values and return a DSML attribute element.
   *
   * @param attrName <code>String</code>
   * @param attrValues <code>List</code>
   * @param ns <code>Namespace</code> of DSML
   * @return <code>Element</code>
   */
  protected Element createDsmlAttribute(
      final String attrName, final List<?> attrValues, final Namespace ns) {
    Element attrElement = DocumentHelper.createElement("");

    if (attrName != null) {
      if (attrName.equalsIgnoreCase("objectclass")) {

        attrElement.setQName(new QName("objectclass", ns));
        if (attrValues != null) {
          final Iterator<?> i = attrValues.iterator();
          while (i.hasNext()) {
            final Object rawValue = i.next();
            String value = null;
            boolean isBase64 = false;
            if (rawValue instanceof String) {
              value = (String) rawValue;
            } else if (rawValue instanceof byte[]) {
              value = LdapUtil.base64Encode((byte[]) rawValue);
              isBase64 = true;
            } else {
              if (this.logger.isWarnEnabled()) {
                this.logger.warn("Could not cast attribute value as a byte[]" + " or a String");
              }
            }
            if (value != null) {
              final Element ocValueElement = attrElement.addElement(new QName("oc-value", ns));
              ocValueElement.addText(value);
              if (isBase64) {
                ocValueElement.addAttribute("encoding", "base64");
              }
            }
          }
        }
      } else {
        attrElement = super.createDsmlAttribute(attrName, attrValues, ns);
      }
    }

    return attrElement;
  }
  public void getAddNode(
      String filePath, String xPath, String newNode, Map<String, String> attrMap, String text)
      throws Exception {

    if (getQueryNode(filePath, xPath, newNode, attrMap, text) < 1) {
      Document document = getPath(filePath, "UTF-8");
      List list = document.selectNodes(xPath);
      System.out.println(xPath);
      Element element = (Element) list.get(0);
      Element newElement = element.addElement(newNode);
      for (Iterator localIterator = attrMap.entrySet().iterator(); localIterator.hasNext(); ) {
        Map.Entry entry = (Map.Entry) localIterator.next();
        newElement.addAttribute((String) entry.getKey(), (String) entry.getValue());
      }
      if ((text != null) && (text.trim().length() > 0)) newElement.addText(text);

      getXMLWrite(document, filePath);
      System.out.println("修改" + xPath + "成功");
    } else {
      System.out.println("已添");
    }
  }
  @Test
  public void testValidateVarElement() {
    Document document = DocumentHelper.createDocument();

    Element element = document.addElement("var");

    element.addAttribute("line-number", "1");
    element.addAttribute("name", "name");
    element.addAttribute("value", "value");

    PoshiRunnerValidation.validateVarElement(element, "ValidateVarElement.macro");

    Assert.assertEquals("validateVarElement is failing", "", getExceptionMessage());

    document = DocumentHelper.createDocument();

    element = document.addElement("var");

    element.addAttribute("line-number", "1");
    element.addAttribute("name", "name");
    element.addText("value");

    PoshiRunnerValidation.validateVarElement(element, "ValidateVarElement.macro");

    Assert.assertEquals("validateVarElement is failing", "", getExceptionMessage());

    document = DocumentHelper.createDocument();

    element = document.addElement("var");

    element.addAttribute("line-number", "1");
    element.addAttribute("name", "name");

    PoshiRunnerValidation.validateVarElement(element, "ValidateVarElement.macro");

    Assert.assertEquals(
        "validateVarElement is failing", "Missing value attribute", getExceptionMessage());
  }
  protected Element addRootPhysicalDescriptionForm(Element modsRootEl) {
    ModsTypeClient mods = getFirstMods();
    List<StringPlusAuthorityPlusTypeClient> physDescForms = null;
    Element physDescEl = modsRootEl.addElement(new QName("physicalDescription", Namespaces.mods));

    if (mods != null
        && mods.getPhysicalDescription() != null
        && mods.getPhysicalDescription().size() > 0
        && mods.getPhysicalDescription().get(0).getForm() != null
        && mods.getPhysicalDescription().get(0).getForm().size() > 0) {
      physDescForms = mods.getPhysicalDescription().get(0).getForm();

      for (StringPlusAuthorityPlusTypeClient physDescForm : physDescForms) {
        String authority = physDescForm.getAuthority();
        String form = physDescForm.getValue();
        if (authority != null && form != null) {
          Element formEl = physDescEl.addElement(new QName("form", Namespaces.mods));
          formEl.addAttribute("authority", authority);
          formEl.addText(form);
        }
      }
    }
    return physDescEl;
  }
Beispiel #28
0
  public static List<Element> getIBAElement(IBAHolder ibaHolder)
      throws RemoteException, WTException {
    List<Element> list = new ArrayList<Element>();

    ibaHolder =
        (WTPart)
            IBAValueHelper.service.refreshAttributeContainer(ibaHolder, null, Locale.CHINA, null);
    DefaultAttributeContainer defaultattributecontainer =
        (DefaultAttributeContainer) ibaHolder.getAttributeContainer();
    if (defaultattributecontainer != null) {
      AttributeDefDefaultView aattributedefdefaultview[] =
          defaultattributecontainer.getAttributeDefinitions();
      Element iba = null;
      for (int i = 0; i < aattributedefdefaultview.length; i++) {
        AbstractValueView aabstractvalueview[] =
            defaultattributecontainer.getAttributeValues(aattributedefdefaultview[i]);

        if (aabstractvalueview != null) {
          String type = "string";
          if (aattributedefdefaultview[i] instanceof BooleanDefView) type = "boolean";
          else if (aattributedefdefaultview[i] instanceof FloatDefView) type = "float";
          else if (aattributedefdefaultview[i] instanceof IntegerDefView) type = "integer";

          iba = new BaseElement("ibaAtt");
          iba.addAttribute("Name", aattributedefdefaultview[i].getDisplayName());
          iba.addAttribute("Type", type);

          iba.addText(
              IBAValueUtility.getLocalizedIBAValueDisplayString(
                  aabstractvalueview[0], Locale.CHINA));
          list.add(iba);
        }
      }
    }
    return list;
  }
Beispiel #29
0
  @Override
  // Implementation methods
  // -------------------------------------------------------------------------
  protected Document parseDocument() throws DocumentException, IOException, XmlPullParserException {
    DocumentFactory df = getDocumentFactory();
    Document document = df.createDocument();
    Element parent = null;
    XmlPullParser pp = getXPPParser();
    pp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);

    while (true) {
      int type = pp.nextToken();

      switch (type) {
        case XmlPullParser.PROCESSING_INSTRUCTION:
          {
            String text = pp.getText();
            int loc = text.indexOf(' ');

            if (loc >= 0) {
              String target = text.substring(0, loc);
              String txt = text.substring(loc + 1);
              document.addProcessingInstruction(target, txt);
            } else {
              document.addProcessingInstruction(text, "");
            }

            break;
          }

        case XmlPullParser.COMMENT:
          {
            if (parent != null) {
              parent.addComment(pp.getText());
            } else {
              document.addComment(pp.getText());
            }

            break;
          }

        case XmlPullParser.CDSECT:
          {
            if (parent != null) {
              parent.addCDATA(pp.getText());
            } else {
              String msg = "Cannot have text content outside of the " + "root document";
              throw new DocumentException(msg);
            }

            break;
          }

        case XmlPullParser.END_DOCUMENT:
          return document;

        case XmlPullParser.START_TAG:
          {
            QName qname =
                (pp.getPrefix() == null)
                    ? df.createQName(pp.getName(), pp.getNamespace())
                    : df.createQName(pp.getName(), pp.getPrefix(), pp.getNamespace());
            Element newElement = df.createElement(qname);
            int nsStart = pp.getNamespaceCount(pp.getDepth() - 1);
            int nsEnd = pp.getNamespaceCount(pp.getDepth());

            for (int i = nsStart; i < nsEnd; i++) {
              if (pp.getNamespacePrefix(i) != null) {
                newElement.addNamespace(pp.getNamespacePrefix(i), pp.getNamespaceUri(i));
              }
            }

            for (int i = 0; i < pp.getAttributeCount(); i++) {
              QName qa =
                  (pp.getAttributePrefix(i) == null)
                      ? df.createQName(pp.getAttributeName(i))
                      : df.createQName(
                          pp.getAttributeName(i),
                          pp.getAttributePrefix(i),
                          pp.getAttributeNamespace(i));
              newElement.addAttribute(qa, pp.getAttributeValue(i));
            }

            if (parent != null) {
              parent.add(newElement);
            } else {
              document.add(newElement);
            }

            parent = newElement;

            break;
          }

        case XmlPullParser.END_TAG:
          {
            if (parent != null) {
              parent = parent.getParent();
            }

            break;
          }

        case XmlPullParser.ENTITY_REF:
        case XmlPullParser.TEXT:
          {
            String text = pp.getText();

            if (parent != null) {
              parent.addText(text);
            } else {
              String msg = "Cannot have text content outside of the " + "root document";
              throw new DocumentException(msg);
            }

            break;
          }

        default:
          break;
      }
    }
  }
Beispiel #30
0
 private static Element writeUnknown(Element parentElement, UnknownAction action) {
   Element element = parentElement.addElement("unknownaction");
   element.addAttribute("code", Integer.toString(action.getCode()));
   element.addText(Base64.encode(action.getData()));
   return element;
 }