示例#1
0
  @SuppressWarnings("unchecked")
  public final <T> T instance(String item, Object index) {
    ExtendedObject object;
    ComplexDocument document;
    ComplexModelItem cmodelitem = cmodel.getItems().get(item);

    if (cmodelitem.model != null) {
      object = new ExtendedObject(cmodelitem.model);
      if (cmodelitem.index != null) {
        if (index == null) throw new RuntimeException("indexed item can't have null key");
        object.set(cmodelitem.index, index);
      }
      add(object);
      return (T) object;
    }

    document = new ComplexDocument(cmodelitem.cmodel);
    if (cmodelitem.index != null) {
      document.set(cmodelitem.index, index);
    } else
      for (DocumentModelKey key : cmodelitem.cmodel.getHeader().getKeys()) {
        document.set(key.getModelItemName(), index);
        break;
      }
    add(document);
    return (T) document;
  }
示例#2
0
 /**
  * @param field
  * @param value
  */
 public final void set(String field, Object value) {
   header.set(field, value);
 }