Class WffBMArray
java.lang.Object
- All Implemented Interfaces:
WffBMData
,WffData
,Serializable
,Cloneable
,Iterable<Object>
,Collection<Object>
,Deque<Object>
,List<Object>
,Queue<Object>
- Direct Known Subclasses:
WffBMNumberArray
The java array object representation for JavaScript array.
Sample code :-
Sample code :-
WffBMObject bmObject = new WffBMObject();
WffBMArray stringArray = new WffBMArray(BMValueType.STRING);
stringArray.add("array value 1");
stringArray.add("array value 2");
bmObject.put("stringArray", BMValueType.BM_ARRAY, stringArray);
WffBMArray numberArray = new WffBMArray(BMValueType.NUMBER);
numberArray.add(555);
numberArray.add(5);
numberArray.add(55);
bmObject.put("numberArray", BMValueType.BM_ARRAY, numberArray);
// to store bytes in an array use WffBMByteArray
WffBMByteArray byteArray = new WffBMByteArray();
byteArray.write("こんにちは WFFWEB".getBytes(StandardCharsets.UTF_8));
bmObject.put("byteArray", BMValueType.BM_BYTE_ARRAY, byteArray);
WffBMArray booleanArray = new WffBMArray(BMValueType.BOOLEAN);
booleanArray.add(true);
booleanArray.add(false);
booleanArray.add(true);
bmObject.put("booleanArray", BMValueType.BM_ARRAY, booleanArray);
WffBMArray regexArray = new WffBMArray(BMValueType.REG_EXP);
regexArray.add("[w]");
regexArray.add("[f]");
regexArray.add("[f]");
bmObject.put("regexArray", BMValueType.BM_ARRAY, regexArray);
WffBMArray funcArray = new WffBMArray(BMValueType.FUNCTION);
funcArray.add("function(arg) {console.log(arg);}");
funcArray.add("function(arg1) {console.log(arg1);}");
funcArray.add("function(arg2) {console.log(arg2);}");
bmObject.put("funcArray", BMValueType.BM_ARRAY, funcArray);
WffBMArray nullArray = new WffBMArray(BMValueType.NULL);
nullArray.add(null);
nullArray.add(null);
nullArray.add(null);
bmObject.put("nullArray", BMValueType.BM_ARRAY, nullArray);
WffBMArray undefinedArray = new WffBMArray(BMValueType.UNDEFINED);
undefinedArray.add(null);
undefinedArray.add(null);
undefinedArray.add(null);
bmObject.put("undefinedArray", BMValueType.BM_ARRAY, undefinedArray);
WffBMArray arrayArray = new WffBMArray(BMValueType.BM_ARRAY);
arrayArray.add(funcArray);
arrayArray.add(funcArray);
arrayArray.add(funcArray);
bmObject.put("arrayArray", BMValueType.BM_ARRAY, arrayArray);
WffBMArray objectArray = new WffBMArray(BMValueType.BM_OBJECT);
objectArray.add(bmObject.clone());
objectArray.add(bmObject.clone());
objectArray.add(bmObject.clone());
bmObject.put("objectArray", BMValueType.BM_ARRAY, objectArray);
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorDescriptionWffBMArray
(byte[] bmArrayBytes) WffBMArray
(byte[] bmArrayBytes, boolean outer) WffBMArray
(BMValueType valueType) WffBMArray
(BMValueType valueType, boolean outer) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
build()
byte[]
build
(boolean outer) Deprecated.building bytes implementation doesn't throw UnsupportedEncodingException so deprecated this method.byte[]
buildBytes
(boolean outer) gets value type of this array only if it contains any value otherwise returnsnull
.boolean
isOuter()
void
setOuter
(boolean outer) Methods inherited from class java.util.LinkedList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, spliterator, toArray, toArray
Methods inherited from class java.util.AbstractSequentialList
iterator
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, replaceAll, retainAll, sort, subList
-
Constructor Details
-
WffBMArray
-
WffBMArray
-
WffBMArray
public WffBMArray(byte[] bmArrayBytes) -
WffBMArray
public WffBMArray(byte[] bmArrayBytes, boolean outer)
-
-
Method Details
-
isOuter
public boolean isOuter() -
setOuter
public void setOuter(boolean outer) -
build
public byte[] build() -
build
Deprecated.building bytes implementation doesn't throw UnsupportedEncodingException so deprecated this method. The same goal can be achieved using buildBytes method.NB: use buildBytes instead of this method.- Specified by:
build
in interfaceWffBMData
- Parameters:
outer
-- Returns:
- the bytes representation of the object
- Throws:
UnsupportedEncodingException
- throwing this exception will be removed in future version because its internal implementation will never make this exception due to the code changes since 3.0.1.- Since:
- 1.1.5
-
buildBytes
public byte[] buildBytes(boolean outer) - Specified by:
buildBytes
in interfaceWffBMData
- Parameters:
outer
-- Returns:
- bytes for this WffBMArray object
-
getValueType
gets value type of this array only if it contains any value otherwise returnsnull
.- Returns:
- the value type of this array
- Since:
- 2.1.0
-
getBMType
-