/** * Return true if the constraint has limit the possible value to * be only one, which means the value has been assigned by the archetype * author at design time * * @return true if has */ public boolean hasAssignedValue() { return item.hasAssignedValue(); }
/** * Constructs a PrimitiveObjectConstraint * * @param path * @param occurrences * @param nodeId * @param parent * @param item */ public CPrimitiveObject(String path, Interval<Integer> occurrences, String nodeId, CAttribute parent, CPrimitive item) { super(item == null, path, item == null ? null : item.getType(), occurrences, nodeId, parent, item == null ? null : item.assumedValue()); this.item = item; }
private String createString(CString cs) { if(cs.defaultValue() != null) { return cs.defaultValue(); } else if (cs.getList() != null && cs.getList().size() > 0) { return cs.getList().get(0); } else { return "string value"; } }
protected void printCString(CString cstring, Element out) { if(cstring.getPattern() != null) { printString("pattern", cstring.getPattern(), out); } if(cstring.getList() != null){ printList(cstring.getList(), out); } // TODO: Write 'list_open' element... <list_open> xs:boolean </list_open> [0..1] if(cstring.hasAssumedValue()) { printString("assumed_value", cstring.assumedValue().toString(), out); } }
protected void printCBoolean(CBoolean cboolean, Element out) { printString("true_valid", cboolean.isTrueValid() == true ? "true" : "false", out); printString("false_valid", cboolean.isFalseValid() == true ? "true" : "false", out); if(cboolean.hasAssumedValue()) { printString("assumed_value", cboolean.assumedValue().booleanValue() == true ? "true" : "false", out); } }
/** * True if value is valid with respect to constraint * * @param value * @return true if valid */ @Override public boolean validValue(Object value) { boolean b = ((Boolean) value).booleanValue(); return ((b && isTrueValid()) || !b && isFalseValid()); }
protected void printCInteger(CInteger cinteger, Writer out) throws IOException { if (cinteger.getList() != null) { printList(cinteger.getList(), out); } else { printInterval(cinteger.getInterval(), out); } if(cinteger.assumedValue() != null) { out.write("; "); out.write(cinteger.assumedValue().toString()); } }
protected void printCReal(CReal creal, Writer out) throws IOException { if (creal.getList() != null) { printList(creal.getList(), out); } else { printInterval(creal.getInterval(), out); } if(creal.assumedValue() != null) { out.write("; "); out.write(creal.assumedValue().toString()); } }
/** * The string representation of this expression leaf * * @return string */ public String toString() { String value; /* special case with CString */ if(item instanceof CString) { CString cstr = (CString) item; value = "/" + cstr.getPattern() + "/"; } else { value = item.toString(); } return value; }
private CString cString(String value) { List<String> values = new ArrayList<String>(); values.add(value); CString cstring = new CString(null, values, null); return cstring; }
/** * Return assigned value as data value instance * * @return datavalue or null if not assigned */ @Override public Object assignedValue() { if (!hasAssignedValue()) { return null; } return list.get(0); }
/** * True if value is valid with respect to constraint * * @param value * @return true if valid */ @Override public boolean validValue(Object value) { boolean b = ((Boolean) value).booleanValue(); return ((b && isTrueValid()) || !b && isFalseValid()); }
protected void printCInteger(CInteger cinteger, Writer out) throws IOException { if (cinteger.getList() != null) { printList(cinteger.getList(), out); } else { printInterval(cinteger.getInterval(), out); } if(cinteger.assumedValue() != null) { out.write("; "); out.write(cinteger.assumedValue().toString()); } }
protected void printCReal(CReal creal, Writer out) throws IOException { if (creal.getList() != null) { printList(creal.getList(), out); } else { printInterval(creal.getInterval(), out); } if(creal.assumedValue() != null) { out.write("; "); out.write(creal.assumedValue().toString()); } }
/** * Constructs a PrimitiveObjectConstraint * * @param path * @param occurrences * @param nodeId * @param parent * @param item */ public CPrimitiveObject(String path, Interval<Integer> occurrences, String nodeId, CAttribute parent, CPrimitive item) { super(item == null, path, item == null ? null : item.getType(), occurrences, nodeId, parent, item == null ? null : item.assumedValue()); this.item = item; }
/** * The string representation of this expression leaf * * @return string */ public String toString() { String value; /* special case with CString */ if(item instanceof CString) { CString cstr = (CString) item; value = "/" + cstr.getPattern() + "/"; } else { value = item.toString(); } return value; }
private CString constrainString(String value) { List<String> values = new ArrayList<>(); values.add(value); CString cstring = new CString(null, values, null); return cstring; }
/** * Return true if the constraint has limit the possible value to * be only one, which means the value has been assigned by the archetype * author at design time * * @return true if has */ public boolean hasAssignedValue() { return item.hasAssignedValue(); }
/** * Return assigned value as data value instance * * @return datavalue or null if not assigned */ @Override public Object assignedValue() { if (!hasAssignedValue()) { return null; } return list.get(0); }
private CString cString(String value) { List<String> values = new ArrayList<String>(); values.add(value); CString cstring = new CString(null, values, null); return cstring; }