예제 #1
0
파일: Server.java 프로젝트: hlambertOld/ctk
  /**
   * This method is called to aggregate the list of constant attributes that the widgets relevant to
   * this server provide. This should be called after a constructor sets the widget handles to use
   * or after setWidgets() has been called.
   *
   * @return AttributeNameValues the server constant attributes
   */
  protected Attributes initConstantAttributes() {
    // this protects us against the Widget constructor
    // that calls us too early (we havent' got the widgets yet)
    // it's good practice anyway
    if (widgets == null) {
      return null;
    }

    Attributes atts = new Attributes();
    for (int i = 0; i < widgets.size(); i++) {
      WidgetHandle handle = widgets.getWidgetHandleAt(i);

      DataObject widgetAtts =
          getWidgetConstantAttributes(handle.getHostName(), handle.getPort(), handle.getId());
      String error = new Error(widgetAtts).getError();
      if (error != null) {
        if (error.equals(Error.NO_ERROR)) {
          Attributes wAtts = new Attributes(widgetAtts);
          for (int j = 0; j < wAtts.numAttributes(); j++) {
            AttributeNameValue wAtt = (AttributeNameValue) wAtts.getAttributeAt(j);
            if (atts.getAttributeNameValue(wAtt.getName()) == null) {
              atts.addAttributeNameValue(wAtt);
            }
          }
        }
      }
    }

    atts.addAttributes(setServerConstantAttributes());

    return atts;
  }