org.pepstock.charba.client.utils.RegExpResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of charba Show documentation
Show all versions of charba Show documentation
Charba - J2CL and GWT charts library based on CHART.JS
/**
Copyright 2017 Andrea "Stock" Stocchero
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUString WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.pepstock.charba.client.utils;
import org.pepstock.charba.client.commons.Array;
import org.pepstock.charba.client.commons.NativeName;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
/**
* Array object which maps the java script object.
* A simple wrapper around a homogeneous native array of string values.
*
* @author Andrea "Stock" Stocchero
*/
@JsType(isNative = true, name = NativeName.ARRAY, namespace = JsPackage.GLOBAL)
public final class RegExpResult extends Array {
/**
* To avoid any instantiation
*/
RegExpResult() {
}
/**
* Returns the 0-based index of the match in the string.
*
* @return the 0-based index of the match in the string.
*/
@JsProperty(name = "index")
public final native int index();
/**
* Returns the original string that was matched against.
*
* @return the original string that was matched against.
*/
@JsProperty(name = "input")
public final native String input();
/**
* Returns the index of the last occurrence of the specified element in this array, or -1 if this array does not contain the element.
*
* @param value element to search for
* @return the index of the last occurrence of the specified element in this array, or -1 if this array does not contain the element
*/
public native int lastIndexOf(String value);
/**
* Returns the index of the first occurrence of the specified element in this array, or -1 if this array does not contain the element.
*
* @param value element to search for
* @return the index of the first occurrence of the specified element in this array, or -1 if this array does not contain the element
*/
public native int indexOf(String value);
/**
* Returns a shallow copy of a portion of an array into a new array object selected from begin to end (end not included).
* The original array will not be modified.
*
* @param start Zero-based index at which to begin extraction.
* A negative index can be used, indicating an offset from the end of the sequence.
* If begin is undefined, slice begins from index 0.
* If begin is greater than the length of the sequence, an empty array is returned.
* @param end Zero-based index before which to end extraction. slice
extracts up to but not including end.
* A negative index can be used, indicating an offset from the end of the sequence.
* If end is omitted, slice extracts through the end of the sequence (array.length()). If end is greater than the length of the sequence, slice
extracts
* through to the end of the sequence (array.length()).
* @return A new array containing the extracted elements.
*/
native RegExpResult slice(int start, int end);
/**
* This method changes the contents of an array by removing existing elements and/or adding new elements.
*
* @param start index at which to start changing the array (with origin 0).
* If greater than the length of the array, actual starting index will be set to the length of the array.
* If negative, will begin that many elements from the end of the array (with origin -1) and
* will be set to 0 if absolute value is greater than the length of the array.
* @return an array containing the deleted elements.
* If only one element is removed, an array of one element is returned.
* If no elements are removed, an empty array is returned.
*/
native RegExpResult splice(int start);
/**
* This method changes the contents of an array by removing existing elements and/or adding new elements.
*
* @param start index at which to start changing the array (with origin 0).
* If greater than the length of the array, actual starting index will be set to the length of the array.
* If negative, will begin that many elements from the end of the array (with origin -1) and
* will be set to 0 if absolute value is greater than the length of the array.
* @param deleteCounts indicating the number of old array elements to remove.
* If deleteCount is omitted, or if its value is larger than array.length() - start (that is, if it is greater than the number of elements left in the array,
* starting at start), then all of the elements from start through the end of the array will be deleted.
* If deleteCount is 0 or negative, no elements are removed.
* @return an array containing the deleted elements.
* If only one element is removed, an array of one element is returned.
* If no elements are removed, an empty array is returned.
*/
native RegExpResult splice(int start, int deleteCounts);
/**
* This method changes the contents of an array by removing existing elements and/or adding new elements.
*
* @param start index at which to start changing the array (with origin 0).
* If greater than the length of the array, actual starting index will be set to the length of the array.
* If negative, will begin that many elements from the end of the array (with origin -1) and
* will be set to 0 if absolute value is greater than the length of the array.
* @param deleteCounts indicating the number of old array elements to remove.
* If deleteCount is omitted, or if its value is larger than array.length() - start (that is, if it is greater than the number of elements left in the array,
* starting at start), then all of the elements from start through the end of the array will be deleted.
* If deleteCount is 0 or negative, no elements are removed.
* @param item the element to add to the array, beginning at the start index. If you don't specify any elements, will only remove elements from the array.
* @return an array containing the deleted elements.
* If only one element is removed, an array of one element is returned.
* If no elements are removed, an empty array is returned.
*/
native RegExpResult splice(int start, int deleteCounts, String item);
/**
* Gets the value at a given index.
*
* If no value exists at the given index, a type-conversion error will occur in Development Mode and unpredictable behavior may occur in Production Mode. If the numeric value
* returned is non-integral, it will cause a warning in Development Mode, and may affect the results of mathematical expressions.
*
* @param index the index to be retrieved
* @return the value at the given index
*/
@JsOverlay
public String get(int index) {
return slice(index, index + 1).pop();
}
/**
* Removes the last element from an array and returns that element. This method changes the length of the array.
*
* @return The removed element from the array; null
if the array is empty.
*/
native String pop();
}