Class WffBMArray

  • All Implemented Interfaces:
    WffBMData, WffData, java.io.Serializable
    Direct Known Subclasses:
    WffBMNumberArray


    public class WffBMArray
    extends java.util.LinkedList<java.lang.Object>
    implements WffBMData
    The java array object representation for JavaScript array.
    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("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:
    WffBMByteArray, WffBMObject, Serialized Form
    • Field Summary

      • Fields inherited from class java.util.AbstractList

        modCount
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] build​()  
      byte[] build​(boolean outer)  
      BMType getBMType​()  
      BMValueType getValueType​()
      gets value type of this array only if it contains any value otherwise returns null.
      boolean isOuter​()  
      void setOuter​(boolean outer)  
      • Methods inherited from class java.util.AbstractCollection

        containsAll, isEmpty, removeAll, retainAll, toString
      • Methods inherited from class java.util.AbstractList

        equals, hashCode, listIterator, removeRange, subList
      • Methods inherited from class java.util.AbstractSequentialList

        iterator
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream
      • Methods inherited from interface java.util.Deque

        iterator
      • Methods inherited from interface java.lang.Iterable

        forEach
      • 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 interface java.util.List

        containsAll, equals, hashCode, isEmpty, iterator, listIterator, of, of, of, of, of, of, of, of, of, of, of, of, removeAll, replaceAll, retainAll, sort, subList
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • WffBMArray

        public WffBMArray​(BMValueType valueType)
      • WffBMArray

        public WffBMArray​(BMValueType valueType,
                          boolean outer)
      • WffBMArray

        public WffBMArray​(byte[] bmArrayBytes)
      • WffBMArray

        public WffBMArray​(byte[] bmArrayBytes,
                          boolean outer)
    • Method Detail

      • isOuter

        public boolean isOuter​()
      • setOuter

        public void setOuter​(boolean outer)
      • build

        public byte[] build​()
      • build

        public byte[] build​(boolean outer)
                     throws java.io.UnsupportedEncodingException
        Specified by:
        build in interface WffBMData
        Returns:
        Throws:
        java.io.UnsupportedEncodingException
      • getValueType

        public BMValueType getValueType​()
        gets value type of this array only if it contains any value otherwise returns null.
        Returns:
        the value type of this array
        Since:
        2.1.0