API Reference 0.7.1rikulo_viewDeclaration

Declaration class

A declaration of properties.

class Declaration {
 final Map<String, String> _props;

 Declaration(): _props = new HashMap();

 /** The text representation of the declaration block.
  * Setting this attribute will reset all properties.
  */
 String get text {
   final StringBuffer sb = new StringBuffer();
   for (final String key in _props.keys)
     sb..write(key)..write(':')..write(_props[key])..write(';');
   return sb.toString();
 }
 /// Sets the text representation of the declaration block.
 void set text(String text) {
   _props.clear();

   for (String pair in _s(text).split(';')) {
     pair = pair.trim();
     if (pair.isEmpty)
       continue;
     final int j = pair.indexOf(':');
     if (j > 0) {
       final String key = pair.substring(0, j).trim();
       final String value = pair.substring(j + 1).trim();
       if (!key.isEmpty) {
         setProperty(key, value);
         continue;
       }
     }
     throw new UIError("Unknown declaration: ${pair}");
   }
 }
 /** Returns a collection of properties that are assigned with
  * a non-empty value.
  */
 Iterable<String> get propertyNames {
   return _props.keys;
 }
 /** Retrieves the property's value.
  */
 String getPropertyValue(String propertyName) {
   final String value = _props[propertyName];
   return value != null ? value: "";
 }
 /** Removes the property of the given name.
  */
 String removeProperty(String propertyName) {
   _props.remove(propertyName);
 }
 /** Sets the value of the given property.
  * If the given value is null or empty, the property will be removed.
  *
  * Notice: the value will be trimmed before saving.
  */
 void setProperty(String propertyName, String value) {
   if (value == null || value.isEmpty)
     removeProperty(propertyName);
   else
     _props[propertyName] = value.trim();
 }
}

Subclasses

LayoutDeclaration, ProfileDeclaration

Constructors

new Declaration() #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
Declaration(): _props = new HashMap();

Properties

final Iterable<String> propertyNames #

Returns a collection of properties that are assigned with a non-empty value.

Iterable<String> get propertyNames {
 return _props.keys;
}

String get text #

The text representation of the declaration block. Setting this attribute will reset all properties.

String get text {
 final StringBuffer sb = new StringBuffer();
 for (final String key in _props.keys)
   sb..write(key)..write(':')..write(_props[key])..write(';');
 return sb.toString();
}

void set text(String text) #

Sets the text representation of the declaration block.

void set text(String text) {
 _props.clear();

 for (String pair in _s(text).split(';')) {
   pair = pair.trim();
   if (pair.isEmpty)
     continue;
   final int j = pair.indexOf(':');
   if (j > 0) {
     final String key = pair.substring(0, j).trim();
     final String value = pair.substring(j + 1).trim();
     if (!key.isEmpty) {
       setProperty(key, value);
       continue;
     }
   }
   throw new UIError("Unknown declaration: ${pair}");
 }
}

Methods

String getPropertyValue(String propertyName) #

Retrieves the property's value.

String getPropertyValue(String propertyName) {
 final String value = _props[propertyName];
 return value != null ? value: "";
}

String removeProperty(String propertyName) #

Removes the property of the given name.

String removeProperty(String propertyName) {
 _props.remove(propertyName);
}

void setProperty(String propertyName, String value) #

Sets the value of the given property. If the given value is null or empty, the property will be removed.

Notice: the value will be trimmed before saving.

void setProperty(String propertyName, String value) {
 if (value == null || value.isEmpty)
   removeProperty(propertyName);
 else
   _props[propertyName] = value.trim();
}