コード例 #1
0
  protected HashMap<String, ArrayList<String>> CollectSingleTableData(
      UserData data, String struct) {
    LinkedHashSet<String> s;
    List<String> tmp;

    MetaType mt = data.getUserDataType();
    s = new LinkedHashSet<String>(data.getUserData().keySet());
    HashMap<String, ArrayList<String>> tableVales = new HashMap<String, ArrayList<String>>();
    tmp = new ArrayList<String>();
    /* strip [] from userdata */
    for (String key : s) {

      String newKey = mt.removeIndicesFromStruct(key, struct);
      tmp.add(newKey);
      if (tableVales.containsKey(newKey)) {
        ArrayList<String> tmpVal = tableVales.get(newKey);
        tmpVal.add(data.getUserData().get(key));
        tableVales.put(newKey, tmpVal);
      } else {
        ArrayList<String> tmpVal = new ArrayList<String>();
        tmpVal.add(data.getUserData().get(key));
        tableVales.put(newKey, tmpVal);
      }
    }
    return tableVales;
  }
コード例 #2
0
  /**
   * Creates a plain text representation of a typedef union.
   *
   * @param field The 'typedeffed' union.
   * @param indent The indentation to draw.
   * @param type The complete type.
   */
  private void drawTypedefUnion(MetaUnion field, String indent, MetaType type) {
    String typedefName = type.getFieldTypedefName(field.getDiscriminator());
    if (typedefName != null) {
      writer.write(
          indent + "union " + field.getTypeName() + " switch(" + typedefName + ") {" + newLine);
    } else {
      writer.write(
          indent
              + "union "
              + field.getTypeName()
              + " switch("
              + field.getDiscriminator().getTypeName()
              + ") {"
              + newLine);
    }
    MetaUnionCase[] cases = field.getCases();
    ArrayList labels;

    for (int i = 0; i < cases.length; i++) {
      labels = cases[i].getLabels();

      for (int j = 0; j < labels.size(); j++) {
        if ("".equals(labels.get(j))) {
          writer.write(indent + tab + "default :" + newLine);
        } else {
          writer.write(indent + tab + "case " + labels.get(j) + ":" + newLine);
        }
      }
      this.drawMetaField(cases[i].getField(), indent + tab + tab, type);
    }
    writer.write(indent + "}");
  }
コード例 #3
0
 /**
  * Creates a plain text representation of a primitive.
  *
  * @param field The primitive to create the plain text representation of.
  * @param indent The indentation to draw.
  * @param type The complete type.
  */
 private void drawPrimitive(MetaPrimitive field, String indent, MetaType type) {
   String typedefName = type.getFieldTypedefName(field);
   if (typedefName != null) {
     writer.write(indent + typedefName + " " + field.getName() + ";" + newLine + separator);
   } else {
     writer.write(
         indent + field.getTypeName() + " " + field.getName() + ";" + newLine + separator);
   }
 }
コード例 #4
0
  /**
   * Creates an plain text representation of the supplied type.
   *
   * @param type The type to create a plain text representation of.
   */
  private void setUserDataType(MetaType type) {
    curValue = (String) typeCache.get(type);

    if (curValue == null) {
      MetaField field = type.getRootField();
      writer = new StringWriter();
      this.drawTypedefs(type);
      this.drawMetaField(field, "", type);
      writer.flush();
      curValue = writer.toString();
      typeCache.put(type, curValue);
    }
  }
コード例 #5
0
  /**
   * Creates a plain text representation of a structure.
   *
   * @param field The structure to create the plain text representation of.
   * @param indent The indentation to draw.
   * @param type The complete type.
   */
  private void drawStruct(MetaStruct field, String indent, MetaType type) {
    String typedefName = type.getFieldTypedefName(field);
    if (typedefName != null) {
      writer.write(indent + typedefName + " " + field.getName() + ";" + newLine + separator);
    } else {
      writer.write(indent + "struct " + field.getTypeName() + " {" + newLine);
      MetaField[] fields = field.getFields();

      for (int i = 0; i < fields.length; i++) {
        this.drawMetaField(fields[i], indent + tab, type);
      }
      writer.write(indent + "} " + field.getName() + ";" + newLine + separator);
    }
  }
コード例 #6
0
ファイル: JniCommunicator.java プロジェクト: xrl/opensplice
  public void participantRegisterType(Participant participant, MetaType type)
      throws CommunicationException {
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(participant);
      String xmlType = type.toXML();
      String result = this.jniRegisterType(xmlEntity, xmlType);
      this.checkConnection();

      if (!("<result>OK</result>".equals(result))) {
        throw new CommunicationException(result.substring(8, result.length() - 9));
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Could not register type.");
    }
  }
コード例 #7
0
  /**
   * Creates a plain text representation of a enumeration.
   *
   * @param field The enumeration to create the plain text representation of.
   * @param indent The indentation to draw.
   * @param type The complete type.
   */
  private void drawEnum(MetaEnum field, String indent, MetaType type) {
    String typedefName = type.getFieldTypedefName(field);
    if (typedefName != null) {
      writer.write(indent + typedefName + " " + field.getName() + ";" + newLine + separator);
    } else {
      writer.write(indent + "enum " + field.getTypeName() + " {" + newLine);
      String[] posValues = field.getPosValues();

      for (int i = 0; i < posValues.length; i++) {
        if (i != (posValues.length - 1)) {
          writer.write(indent + tab + posValues[i] + ", " + newLine);
        } else {
          writer.write(indent + tab + posValues[i] + newLine);
        }
      }
      writer.write(indent + "} " + field.getName() + ";" + newLine + separator);
    }
  }
コード例 #8
0
  /**
   * Creates a plain text representation of the typedefs in the type.
   *
   * @param type The type to extract the typedefs from.
   */
  private void drawTypedefs(MetaType type) {
    MetaField field;
    String typedefName;

    LinkedHashMap typedefs = type.getTypedefs();
    Iterator iter = typedefs.keySet().iterator();
    HashSet finished = new HashSet();

    while (iter.hasNext()) {
      field = (MetaField) (iter.next());
      typedefName = (String) (typedefs.get(field));

      if (!(finished.contains(typedefName))) {
        writer.write("typedef ");
        this.drawTypedefMetaField(field, "", type);
        writer.write(" " + typedefName + ";" + newLine + newLine + separator);
        finished.add(typedefName);
      }
    }
  }