Пример #1
0
 @Override
 public void setXML(Element textElem) {
   setMultiLine(Boolean.parseBoolean(textElem.getAttributeValue("multiLine")));
   setReadOnly(Boolean.parseBoolean(textElem.getAttributeValue("readOnly")));
   setLabel(StringEscapeUtils.unescapeXml(textElem.getAttributeValue("label")));
   savedText = textElem.getText();
   setText(StringEscapeUtils.unescapeXml(savedText));
   checkCursorPosition();
 }
 protected boolean next(Text key, Text value) throws IOException {
   if (fsin.getPos() < end) {
     try {
       if (readUntilMatch(START_TITLE_MARKER, false)) {
         if (readUntilMatch(END_TITLE_MARKER, true)) {
           int stop = buffer.getLength() - END_TITLE_MARKER.length;
           key.set(buffer.getData(), 0, stop);
           buffer.reset();
           if (readUntilMatch(START_TEXT_MARKER, false)) {
             if (readUntilMatch(END_TEXT_MARKER, true)) {
               // un-escape the XML entities encoding and
               // re-encode the result as raw UTF8 bytes
               stop = buffer.getLength() - END_TITLE_MARKER.length;
               String xmlEscapedContent = new String(buffer.getData(), 0, stop + 1, UTF8);
               value.set(StringEscapeUtils.unescapeXml(xmlEscapedContent).getBytes(UTF8));
               return true;
             }
           }
         }
       }
     } finally {
       buffer.reset();
     }
   }
   return false;
 }
Пример #3
0
 private String processSequenceXml(String sequence) {
   if (StringUtils.isEmpty(sequence)) {
     return null;
   }
   String processedSequence = StringEscapeUtils.unescapeXml(sequence);
   return processedSequence;
 }
  protected String getDomainIdFromXmi(StringBuilder sb) {
    int datasourceModelTagPosition = sb.indexOf("datasourceModel");
    if (datasourceModelTagPosition != -1) {
      String tag = "<CWM:Description body=";
      int startTagPosition = sb.indexOf(tag, datasourceModelTagPosition);

      int startPosition = startTagPosition + tag.length() + 1;
      int endPosition = sb.indexOf("\"", startPosition);

      return StringEscapeUtils.unescapeXml(sb.substring(startPosition, endPosition));
    } else {
      return null;
    }
  }
Пример #5
0
 /**
  * Convert a string with XML entities to a string without XML entities
  *
  * @param source
  * @return
  */
 public static String unescapeXml(String source) {
   return (StringEscapeUtils.unescapeXml(source));
 }
  private JSONObject convertXMLToJSON(String xmlData) throws JSONException, JAXBException {
    // Unmarshall the xml into a GraphML
    ByteArrayInputStream baiStream = new ByteArrayInputStream(xmlData.getBytes());
    JAXBContext jc = JAXBContext.newInstance(GraphMLUtil.GRAPHML_CLASSES);
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    GraphML graphML = (GraphML) unmarshaller.unmarshal(baiStream);

    // eventually check version for compatibility
    s_logger.info("Importing chart version: {}", graphML.getversion());

    Graph graph = graphML.getGraph();

    JSONObject toReturn = new JSONObject(),
        miscData = null,
        columnJSON,
        nodeJSON = null,
        clusterJSON;
    String cachedClusterJSON = null;
    int columnIdx = -1, rowIdx = -1;
    List<List<JSONObject>> allColumns = new ArrayList<List<JSONObject>>();
    List<JSONObject> currColumn, outColumns = new ArrayList<JSONObject>();

    // first, set up the column and misc JSON data contained in the graph
    for (GraphDataXML data : graph.getdata()) {
      if (data.getkey().startsWith("column")) {
        columnJSON = XML.toJSONObject(data.getvalue());
        columnIdx = Integer.parseInt(data.getkey().substring(6));
        while (columnIdx >= outColumns.size()) {
          outColumns.add(new JSONObject());
        }

        outColumns.set(columnIdx, columnJSON);
        allColumns.add(new ArrayList<JSONObject>());
      } else if (data.getkey().equals("miscData")) {
        miscData = XML.toJSONObject(data.getvalue());
      }
    }

    // next, iterate through the graph nodes and place the JSONObject for each into it's proper
    // row/column
    for (GraphNode node : graph.getnode()) {
      for (GraphData data : node.getdata()) { // parse the goodies from each file node
        if (data.getkey().equals("column")) {
          columnIdx = Integer.parseInt(data.getvalue());
        } else if (data.getkey().equals("row")) {
          rowIdx = Integer.parseInt(data.getvalue());
        }
      }

      for (GraphDataXML data : node.getnodedata()) { // parse the goodies from each data node
        if (data.getkey().equals("fileJSON")) {
          nodeJSON = XML.toJSONObject(data.getvalue());
        } else if (data.getkey().equals("clusterJSON")) {
          cachedClusterJSON = data.getvalue();
        }
      }

      if (nodeJSON != null
          && nodeJSON.has("clusterUIObject")
          && !nodeJSON.get("clusterUIObject").toString().equals("null")) {
        clusterJSON = nodeJSON.getJSONObject("clusterUIObject"); // do annoying cleanup
        insertJSONArray(clusterJSON, "children");
        insertJSONArray(clusterJSON.getJSONObject("spec"), "members");
      }

      if (cachedClusterJSON != null) {
        PermitSet permits = new PermitSet();

        try {
          List<String> entityIds = new LinkedList<String>();
          List<FL_Cluster> allClusters = ClusterHelper.listFromJson(cachedClusterJSON);
          ;
          for (FL_Cluster cluster : allClusters) {
            entityIds.addAll(cluster.getMembers());
            for (FL_Property property : cluster.getProperties()) {
              if (!(property.getRange() instanceof FL_SingletonRange)) continue;
              FL_SingletonRange range = (FL_SingletonRange) property.getRange();
              if (!range.getType().equals(FL_PropertyType.STRING)) continue;
              property.setRange(
                  new SingletonRangeHelper(
                      StringEscapeUtils.unescapeXml((String) range.getValue())));
            }
          }

          final ContextReadWrite contextRW =
              contextCache.getReadWrite(nodeJSON.getString("xfId"), permits);
          contextRW.getContext().addClusters(allClusters);
          contextRW
              .getContext()
              .addEntities(entityAccess.getEntities(entityIds, FL_LevelOfDetail.SUMMARY));
          contextRW.setSimplifiedContext(allClusters);
        } catch (IOException e) {
          throw new ResourceException(
              Status.CLIENT_ERROR_BAD_REQUEST, "Exception during cluster cache processing.", e);
        } finally {
          permits.revoke();
        }
      }

      currColumn = allColumns.get(columnIdx);
      while (rowIdx >= currColumn.size()) {
        currColumn.add(new JSONObject());
      }
      currColumn.set(rowIdx, nodeJSON);
    }

    // place the files as children in the outgoing columns array
    for (int i = 0; i < allColumns.size(); i++) {
      columnJSON = outColumns.get(i);
      columnJSON.put("children", new JSONArray(allColumns.get(i)));
    }

    // finally, place the child columns and misc data in the resulting JSON object
    toReturn.put("children", new JSONArray(outColumns));
    for (String dataKey : JSONObject.getNames(miscData)) {
      toReturn.put(dataKey, miscData.get(dataKey));
    }

    return toReturn;
  }
 public String getType() {
   return StringEscapeUtils.unescapeXml(type);
 }
 public String getName() {
   return StringEscapeUtils.unescapeXml(name);
 }
Пример #9
0
 /** Xml 解码. */
 public static String xmlUnescape(String xmlEscaped) {
   return StringEscapeUtils.unescapeXml(xmlEscaped);
 }
Пример #10
0
 /**
  * 将xml 转换程 字符串
  *
  * @param message 待转换的 数据
  * @return 转换后的字符串
  */
 public static String deXml(final String message) {
   if (isEmpty(message)) {
     return "";
   }
   return StringEscapeUtils.unescapeXml(message);
 }
Пример #11
0
 public static String unescapeXml(String string) {
   return string == null ? null : StringEscapeUtils.unescapeXml(string);
 }