Example #1
0
  /**
   * Sets the value for an "extra" property for this schema element. If a property already exists
   * with the specified name, then it will be overwritten. If the value is {@code null}, then any
   * existing property with the given name will be removed.
   *
   * @param elem The element where to set the extra property
   * @param name The name for the "extra" property. It must not be {@code null}.
   * @param value The value for the "extra" property. If it is {@code null}, then any existing
   *     definition will be removed.
   */
  public static void setExtraProperty(SchemaFileElement elem, String name, String value) {
    ifNull(name);

    if (value == null) {
      elem.getExtraProperties().remove(name);
    } else {
      elem.getExtraProperties().put(name, newLinkedList(value));
    }
  }
Example #2
0
 /**
  * Retrieves the name of a single value property for this schema element.
  *
  * @param elem The element where to get the single value property from
  * @param propertyName The name of the property to get
  * @return The single value for this property, or <code>null</code> if it is this property is not
  *     set.
  */
 public static String getSingleValueProperty(SchemaFileElement elem, String propertyName) {
   List<String> values = elem.getExtraProperties().get(propertyName);
   if (values != null && !values.isEmpty()) {
     return values.get(0);
   }
   return null;
 }
Example #3
0
 /**
  * Retrieves the definition string used to create this attribute type and including the
  * X-SCHEMA-FILE extension.
  *
  * @param elem The element where to get definition from
  * @return The definition string used to create this attribute type including the X-SCHEMA-FILE
  *     extension.
  */
 public static String getDefinitionWithFileName(SchemaFileElement elem) {
   final String schemaFile = getSchemaFile(elem);
   final String definition = elem.toString();
   if (schemaFile != null) {
     int pos = definition.lastIndexOf(')');
     return definition.substring(0, pos).trim()
         + " "
         + SCHEMA_PROPERTY_FILENAME
         + " '"
         + schemaFile
         + "' )";
   }
   return definition;
 }