List of usage examples for com.google.gwt.core.client JsArrayString length
public final native int length() ;
From source file:org.waveprotocol.wave.concurrencycontrol.jso.WaveletSnapshotJsoImpl.java
License:Apache License
@Override @SuppressWarnings("unchecked") public String getParticipant(int n) { initArray(this, keyParticipant); JsArrayString array = getPropertyAsObject(this, keyParticipant).cast(); if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); if (array.length() <= n) throw new IllegalArgumentException("index " + n + ">= array length " + array.length()); return array.get(n); }
From source file:org.waveprotocol.wave.diff.jso.DocumentDiffSnapshotJsoImpl.java
License:Apache License
@Override @SuppressWarnings("unchecked") public String getAddedContributor(int n) { initArray(this, keyAddedContributor); JsArrayString array = getPropertyAsObject(this, keyAddedContributor).cast(); if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); if (array.length() <= n) throw new IllegalArgumentException("index " + n + ">= array length " + array.length()); return array.get(n); }
From source file:org.waveprotocol.wave.diff.jso.DocumentDiffSnapshotJsoImpl.java
License:Apache License
@Override @SuppressWarnings("unchecked") public String getRemovedContributor(int n) { initArray(this, keyRemovedContributor); JsArrayString array = getPropertyAsObject(this, keyRemovedContributor).cast(); if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); if (array.length() <= n) throw new IllegalArgumentException("index " + n + ">= array length " + array.length()); return array.get(n); }
From source file:org.waveprotocol.wave.diff.jso.WaveletDiffSnapshotJsoImpl.java
License:Apache License
@Override @SuppressWarnings("unchecked") public String getAddedParticipant(int n) { initArray(this, keyAddedParticipant); JsArrayString array = getPropertyAsObject(this, keyAddedParticipant).cast(); if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); if (array.length() <= n) throw new IllegalArgumentException("index " + n + ">= array length " + array.length()); return array.get(n); }
From source file:org.waveprotocol.wave.diff.jso.WaveletDiffSnapshotJsoImpl.java
License:Apache License
@Override @SuppressWarnings("unchecked") public String getRemovedParticipant(int n) { initArray(this, keyRemovedParticipant); JsArrayString array = getPropertyAsObject(this, keyRemovedParticipant).cast(); if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); if (array.length() <= n) throw new IllegalArgumentException("index " + n + ">= array length " + array.length()); return array.get(n); }
From source file:org.waveprotocol.wave.federation.jso.ProtocolSignerInfoJsoImpl.java
License:Apache License
@Override @SuppressWarnings("unchecked") public Blob getCertificate(int n) { initArray(this, keyCertificate); JsArrayString array = getPropertyAsObject(this, keyCertificate).cast(); if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); if (array.length() <= n) throw new IllegalArgumentException("index " + n + ">= array length " + array.length()); return new Blob(array.get(n)); }
From source file:org.waveprotocol.wave.federation.jso.ProtocolWaveletDeltaJsoImpl.java
License:Apache License
@Override @SuppressWarnings("unchecked") public String getAddressPath(int n) { initArray(this, keyAddressPath); JsArrayString array = getPropertyAsObject(this, keyAddressPath).cast(); if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); if (array.length() <= n) throw new IllegalArgumentException("index " + n + ">= array length " + array.length()); return array.get(n); }
From source file:org.xwiki.gwt.dom.client.internal.ie.IEOldDOMUtils.java
License:Open Source License
@Override public Node importNode(Document doc, Node externalNode, boolean deep) { switch (externalNode.getNodeType()) { case Node.TEXT_NODE: return doc.createTextNode(externalNode.getNodeValue()); case Node.ELEMENT_NODE: Element externalElement = Element.as(externalNode); Element internalElement = (Element) doc.createElement(externalElement.getTagName()); JsArrayString attrNames = getAttributeNames(externalElement); for (int i = 0; i < attrNames.length(); i++) { String attrName = attrNames.get(i); internalElement.setAttribute(attrName, externalElement.getAttribute(attrName)); }/*ww w .ja v a 2s . c o m*/ if (deep) { // TODO } return internalElement; default: throw new IllegalArgumentException("Cannot import node of type " + externalNode.getNodeType() + "!"); } }
From source file:org.xwiki.gwt.user.client.BackForwardCache.java
License:Open Source License
/** * Parses the given string and extracts a map of key-value pairs. * // w w w .j a va 2 s. c o m * @param data the string to be deserialized * @return the map whose serialization is the given string * @see #serialize(Map) */ protected Map<String, String> deserialize(String data) { Map<String, String> map = new HashMap<String, String>(); if (!StringUtils.isEmpty(data)) { JavaScriptObject jsObject = JavaScriptObject.fromJson(data); JsArrayString keys = jsObject.getKeys(); for (int i = 0; i < keys.length(); i++) { String key = keys.get(i); Object value = jsObject.get(key); if (value != null) { map.put(key, String.valueOf(value)); } } } return map; }
From source file:org.xwiki.gwt.user.client.ui.rta.cmd.internal.ToggleInlineStyleExecutable.java
License:Open Source License
/** * Removes the underlying style from the given text node. * /*ww w .j a va 2s . c o m*/ * @param text the target text node * @param firstCharIndex the first character on which we remove the style * @param lastCharIndex the last character on which we remove the style * @return a text fragment indicating what has been unformatted */ protected TextFragment removeStyle(Text text, int firstCharIndex, int lastCharIndex) { // Make sure we remove the style only from the selected text. text.crop(firstCharIndex, lastCharIndex); // Look for the element ancestor that has the underlying style. Node child = text; Node parent = child.getParentNode(); while (parent != null && matchesStyle(parent) && domUtils.isInline(parent)) { domUtils.isolate(child); child = child.getParentNode(); parent = child.getParentNode(); } if (tagName.equalsIgnoreCase(child.getNodeName())) { // The style is enforced by a formatting element. We have to remove or rename it. Element element = (Element) child; if (element.hasAttributes()) { // We must keep the attributes. Let's rename the element. Element replacement = element.getOwnerDocument().createSpanElement().cast(); JsArrayString attributes = element.getAttributeNames(); for (int i = 0; i < attributes.length(); i++) { replacement.setAttribute(attributes.get(i), element.getAttribute(attributes.get(i))); } replacement.appendChild(element.extractContents()); element.getParentNode().replaceChild(replacement, element); } else { // We remove the element but keep its child nodes. element.unwrap(); } } else { if (child.getNodeType() != Node.ELEMENT_NODE) { // Wrap the child with a span element. Node wrapper = child.getOwnerDocument().createSpanElement(); child.getParentNode().replaceChild(wrapper, child); wrapper.appendChild(child); child = wrapper; } // The style is enforced using CSS. Let's reset the style property to its default value. ((Element) child).getStyle().setProperty(getProperty().getJSName(), getProperty().getDefaultValue()); } return new TextFragment(text, 0, text.getLength()); }