Package org.apache.vinci.transport

Examples of org.apache.vinci.transport.KeyValuePair


      if (!done) {
        cleanup(); // release the cas back to the pool if we didn't parse successfully.
      }
    }
    if (error != null) {
      return new KeyValuePair(TransportConstants.ERROR_KEY, new FrameLeaf(error));
    }
    // Debug.p("Testing: " + extraDataFrame.toXML());
    return null;
  }
View Full Code Here


        int children = 1 + extraDataFrame.getKeyValuePairCount();
        XTalkTransporter.writeInt(children, os); // 1 child (KEYS) + extra data fields...
        started = false; // triggers first startElement() call to write "KEYS" instead of "CAS"
        // Write extra data...
        for (int i = 0; i < extraDataFrame.getKeyValuePairCount(); i++) {
          KeyValuePair k = extraDataFrame.getKeyValuePair(i);
          os.write(XTalkTransporter.ELEMENT_MARKER);
          XTalkTransporter.stringToBin(k.getKey(), os, mybuf);
          XTalkTransporter.writeInt(0, os); // no attributes
          XTalkTransporter.writeInt(1, os); // 1 child (pcdata)
          os.write(XTalkTransporter.STRING_MARKER);
          XTalkTransporter.stringToBin(k.getValueAsString(), os, mybuf);
        }
      } catch (IOException e) {
        throw wrapAsSAXException(e);
      }
    }
View Full Code Here

      // Check if it is a Service or a ServiceAlias and parse accordingly
      if (Q.fgetString("TARGET") == null) {
        H = new Hashtable();
        int total = Q.getKeyValuePairCount();
        KeyValuePair P = null;
        for (int j = 0; j < total; j++) {
          P = Q.getKeyValuePair(j);
          if (P.isValueALeaf()) {
            H.put(P.getKey(), P.getValueAsString());
          } else {
            H.put(P.getKey(), P.getValue());
          }
        }

        S[i] = new Service(H);
      } else {
View Full Code Here

  protected void _parse(VinciFrame aFrame) throws SAXException {
    int count = aFrame.getKeyValuePairCount();

    for (int i = 0; i < count; i++) {
      KeyValuePair kvp = aFrame.getKeyValuePair(i);
      boolean isIndexed = false;

      FrameComponent val = kvp.getValue();

      // read attributes
      AttributesImpl attrs = new AttributesImpl();

      Attributes vinciAttrs = null;
      if (val instanceof AFrame) {
        vinciAttrs = ((AFrame) val).getAttributes();
      } else if (val instanceof AFrameLeaf) {
        vinciAttrs = ((AFrameLeaf) val).getAttributes();
      }

      if (vinciAttrs != null) {
        for (int j = 0; j < vinciAttrs.getKeyValuePairCount(); j++) {
          KeyValuePair attr = vinciAttrs.getKeyValuePair(j);
          String attrName = attr.getKey();
          String attrVal = attr.getValueAsString();
          attrs.addAttribute("", attrName, attrName, "CDATA", attrVal);
          if (attrName.equals("_indexed")) {
            isIndexed = true;
          }
        }
View Full Code Here

  public static CasData addKeysToDataCas(CasData dataCas, AFrame aFrame) throws Exception {
    try {
      aFrame = aFrame.fgetAFrame(Constants.KEYS);
      int frameCount = aFrame.getKeyValuePairCount();
      for (int i = 0; i < frameCount; i++) {
        KeyValuePair kvp = aFrame.getKeyValuePair(i);
        String featureStructureType = kvp.getKey();
        // Convert WF keys from ':' representation to '_colon_'
        if (featureStructureType
                .indexOf(org.apache.uima.collection.impl.cpm.Constants.SHORT_COLON_TERM) > -1) {
          featureStructureType = StringUtils.replaceAll(featureStructureType,
                  org.apache.uima.collection.impl.cpm.Constants.SHORT_COLON_TERM,
                  org.apache.uima.collection.impl.cpm.Constants.LONG_COLON_TERM);
        }
        // Convert WF keys from '-' representation to '_dash_'
        if (featureStructureType
                .indexOf(org.apache.uima.collection.impl.cpm.Constants.SHORT_DASH_TERM) > -1) {
          featureStructureType = StringUtils.replaceAll(featureStructureType,
                  org.apache.uima.collection.impl.cpm.Constants.SHORT_DASH_TERM,
                  org.apache.uima.collection.impl.cpm.Constants.LONG_DASH_TERM);
        }

        FeatureStructure vfs = new FeatureStructureImpl();
        vfs.setType(featureStructureType);

        FrameLeaf leafFrame = kvp.getValueAsLeaf();

        PrimitiveValue pv = new PrimitiveValueImpl(leafFrame.toString());
        vfs.setFeatureValue(featureStructureType, pv);
        dataCas.addFeatureStructure(vfs);
      }
View Full Code Here

    VinciFrame service = in.fgetVinciFrame("SERVICE");

    Hashtable H = new Hashtable();

    int total = service.getKeyValuePairCount();
    KeyValuePair P;
    for (int i = 0; i < total; i++) {
      P = service.getKeyValuePair(i);
      if (P.isValueALeaf()) {
        H.put(P.getKey(), P.getValueAsString());
      } else {
        H.put(P.getKey(), P.getValue());
      }
    }

    String level = (String) H.get("LEVEL");
    if (strip(level) == null) {
View Full Code Here

    VinciFrame service = in.fgetVinciFrame("SERVICE");

    Hashtable H = new Hashtable();

    int total = service.getKeyValuePairCount();
    KeyValuePair P = null;
    for (int i = 0; i < total; i++) {
      P = service.getKeyValuePair(i);

      if (P.isValueALeaf()) {
        H.put(P.getKey(), P.getValueAsString());
      } else {
        H.put(P.getKey(), P.getValue());
      }
    }

    String level = (String) H.get("LEVEL");
    if (strip(level) == null)
View Full Code Here

    VinciFrame service = in.fgetVinciFrame("SERVICE");

    Hashtable H = new Hashtable();

    int total = service.getKeyValuePairCount();
    KeyValuePair P;
    for (int i = 0; i < total; i++) {
      P = service.getKeyValuePair(i);
      if (P.isValueALeaf()) {
        H.put(P.getKey(), P.getValueAsString());
      } else {
        H.put(P.getKey(), P.getValue());
      }
    }

    boolean ok = false;
View Full Code Here

  public static CasData addKeysToDataCas(CasData dataCas, AFrame aFrame) throws Exception {
    try {
      aFrame = aFrame.fgetAFrame(Constants.KEYS);
      int frameCount = aFrame.getKeyValuePairCount();
      for (int i = 0; i < frameCount; i++) {
        KeyValuePair kvp = aFrame.getKeyValuePair(i);
        String featureStructureType = kvp.getKey();
        // Convert WF keys from ':' representation to '_colon_'
        if (featureStructureType
                .indexOf(org.apache.uima.collection.impl.cpm.Constants.SHORT_COLON_TERM) > -1) {
          featureStructureType = StringUtils.replaceAll(featureStructureType,
                  org.apache.uima.collection.impl.cpm.Constants.SHORT_COLON_TERM,
                  org.apache.uima.collection.impl.cpm.Constants.LONG_COLON_TERM);
        }
        // Convert WF keys from '-' representation to '_dash_'
        if (featureStructureType
                .indexOf(org.apache.uima.collection.impl.cpm.Constants.SHORT_DASH_TERM) > -1) {
          featureStructureType = StringUtils.replaceAll(featureStructureType,
                  org.apache.uima.collection.impl.cpm.Constants.SHORT_DASH_TERM,
                  org.apache.uima.collection.impl.cpm.Constants.LONG_DASH_TERM);
        }

        FeatureStructure vfs = new FeatureStructureImpl();
        vfs.setType(featureStructureType);

        FrameLeaf leafFrame = kvp.getValueAsLeaf();

        PrimitiveValue pv = new PrimitiveValueImpl(leafFrame.toString());
        vfs.setFeatureValue(featureStructureType, pv);
        dataCas.addFeatureStructure(vfs);
      }
View Full Code Here

    VinciFrame service = in.fgetVinciFrame("SERVICE");

    Hashtable H = new Hashtable();

    int total = service.getKeyValuePairCount();
    KeyValuePair P;
    for (int i = 0; i < total; i++) {
      P = service.getKeyValuePair(i);
      if (P.isValueALeaf()) {
        H.put(P.getKey(), P.getValueAsString());
      } else {
        H.put(P.getKey(), P.getValue());
      }
    }

    String level = (String) H.get("LEVEL");
    if (strip(level) == null) {
View Full Code Here

TOP

Related Classes of org.apache.vinci.transport.KeyValuePair

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.