Java Code Examples for com.google.gwt.core.client.JsArrayString#length()

The following examples show how to use com.google.gwt.core.client.JsArrayString#length() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsEditorUtils.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Transform a Javascript object (array or string) to
 * a StringSet.
 *
 * @param obj an array or string
 * @return
 */
public static StringSet toStringSet(JavaScriptObject obj) throws IllegalStateException {

  StringSet set = CollectionUtils.createStringSet();

  // from array
  JsArrayString array = asArray(obj);
  if (array != null) {
    for (int i = 0; i < array.length(); i++)
      set.add(array.get(i));
  }


  // from string
  String s = asString(obj);
  if (s!=null)
    set.add(s);

  return set;
}
 
Example 2
Source File: BucketsImpl.java    From requestor with Apache License 2.0 6 votes vote down vote up
public boolean isEquals(BucketsOverlay other) {
    if (super.equals(other))
        return true;

    final JsArrayString keys = getKeysNative();
    final JsArrayString otherKeys = other.getKeysNative();
    if (arraysEquals(keys, otherKeys)) {
        for (int i = 0; i < keys.length(); i++) {
            if (!arraysEquals(getNative(keys.get(i)), other.getNative(otherKeys.get(i)))) {
                return false;
            }
        }
        return true;
    }

    return false;
}
 
Example 3
Source File: SliderBase.java    From gwtbootstrap3-extras with Apache License 2.0 6 votes vote down vote up
private List<String> getStringArrayAttribute(SliderOption option, List<String> defaultValue) {

        // Get array attribute
        JsArrayString array = null;
        if (isAttached()) {
            array = getStringArrayAttribute(getElement(), option.getName());
        } else {
            String value = attributeMixin.getAttribute(option.getDataAttribute());
            if (value != null && !value.isEmpty()) {
                array = JsonUtils.safeEval(value);
            }
        }

        // Attribute not set
        if (array == null) {
            return defaultValue;
        }

        // Put array to list
        List<String> list = new ArrayList<String>(array.length());
        for (int i = 0; i < array.length(); i++) {
            list.add(array.get(i));
        }
        return list;
    }
 
Example 4
Source File: Projections.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private static List<String> getProj4jsProjections() {
	List<String> projections = new ArrayList<String>(); 
				
	JsArrayString projDefs = getProjDefs();

	for (int i = 0; i < projDefs.length(); i++) {
		projections.add(projDefs.get(i).trim());
	}

	return projections;
}
 
Example 5
Source File: JsRegExp.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getMatches(String test) {
  JsArrayString matches = matches(regExp, test);
  if (matches != null && matches.length() > 0) {
    List<String> result = new ArrayList<String>(matches.length());
    for (int i = 0; i < matches.length(); ++i) {
      result.add(matches.get(i));
    }
    return result;
  }
  return new ArrayList<String>();
}
 
Example 6
Source File: JsRegExp.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getMatches(String test) {
  JsArrayString matches = matches(regExp, test);
  if (matches != null && matches.length() > 0) {
    List<String> result = new ArrayList<String>(matches.length());
    for (int i = 0; i < matches.length(); ++i) {
      result.add(matches.get(i));
    }
    return result;
  }
  return new ArrayList<String>();
}
 
Example 7
Source File: MultipleSelect.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getValue() {
    if (isAttached()) {
        JsArrayString arr = getValue(getElement());
        List<String> result = new ArrayList<>(arr.length());
        for (int i = 0; i < arr.length(); i++) {
            result.add(arr.get(i));
        }
        return result;
    }
    return getSelectedValues();
}
 
Example 8
Source File: TagsInputBase.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
protected static List<String> toMultiValue(JavaScriptObject js_multi_value) {
    List<String> retValue = new ArrayList<String>();
    
    if (js_multi_value != null) {
        JsArrayString js_string_array = js_multi_value.cast();
        
        for(int i=0; i<js_string_array.length(); i++) {
            retValue.add(js_string_array.get(i));
        }
    }
    
    return retValue;
}
 
Example 9
Source File: GwtStatisticsEvent.java    From swellrt with Apache License 2.0 4 votes vote down vote up
public final StatisticsEvent asEvent() {
  return new StatisticsEvent() {
    //@Override
    public String getModuleName() {
      return GwtStatisticsEvent.this.getModuleName();
    }
    //@Override
    public String getSubSystem() {
      return GwtStatisticsEvent.this.getSubSystem();
    }
    //@Override
    public String getEventGroupKey() {
      return GwtStatisticsEvent.this.getEventGroupKey();
    }
    //@Override
    public double getMillis() {
      return GwtStatisticsEvent.this.getMillis();
    }
    //@Override
    public Iterator<String> getExtraParameterNames() {
      final JsArrayString names = getExtraParameterNames0();
      return new Iterator<String>() {
        private int idx = 0;

        //@Override
        public boolean hasNext() {
          return idx < names.length();
        }

        //@Override
        public String next() {
          return names.get(idx++);
        }

        //@Override
        public void remove() {
          throw new RuntimeException("parameter names are read-only");
        }
      };
    }
    //@Override
    public Object getExtraParameter(String name) {
      return GwtStatisticsEvent.this.getExtraParameter(name);
    }
  };
}
 
Example 10
Source File: GwtStatisticsEvent.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
public final StatisticsEvent asEvent() {
  return new StatisticsEvent() {
    //@Override
    public String getModuleName() {
      return GwtStatisticsEvent.this.getModuleName();
    }
    //@Override
    public String getSubSystem() {
      return GwtStatisticsEvent.this.getSubSystem();
    }
    //@Override
    public String getEventGroupKey() {
      return GwtStatisticsEvent.this.getEventGroupKey();
    }
    //@Override
    public double getMillis() {
      return GwtStatisticsEvent.this.getMillis();
    }
    //@Override
    public Iterator<String> getExtraParameterNames() {
      final JsArrayString names = getExtraParameterNames0();
      return new Iterator<String>() {
        private int idx = 0;

        //@Override
        public boolean hasNext() {
          return idx < names.length();
        }

        //@Override
        public String next() {
          return names.get(idx++);
        }

        //@Override
        public void remove() {
          throw new RuntimeException("parameter names are read-only");
        }
      };
    }
    //@Override
    public Object getExtraParameter(String name) {
      return GwtStatisticsEvent.this.getExtraParameter(name);
    }
  };
}
 
Example 11
Source File: GwtStatisticsEvent.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public final StatisticsEvent asEvent() {
  return new StatisticsEvent() {
    //@Override
    public String getModuleName() {
      return GwtStatisticsEvent.this.getModuleName();
    }
    //@Override
    public String getSubSystem() {
      return GwtStatisticsEvent.this.getSubSystem();
    }
    //@Override
    public String getEventGroupKey() {
      return GwtStatisticsEvent.this.getEventGroupKey();
    }
    //@Override
    public double getMillis() {
      return GwtStatisticsEvent.this.getMillis();
    }
    //@Override
    public Iterator<String> getExtraParameterNames() {
      final JsArrayString names = getExtraParameterNames0();
      return new Iterator<String>() {
        private int idx = 0;

        //@Override
        public boolean hasNext() {
          return idx < names.length();
        }

        //@Override
        public String next() {
          return names.get(idx++);
        }

        //@Override
        public void remove() {
          throw new RuntimeException("parameter names are read-only");
        }
      };
    }
    //@Override
    public Object getExtraParameter(String name) {
      return GwtStatisticsEvent.this.getExtraParameter(name);
    }
  };
}