public class Objs extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
Objs.Constructor<T extends Objs>
Factory for one subclass of
Objs wrapper. |
static class |
Objs.Property<T>
Represents a property of an
Objs object. |
Modifier and Type | Field and Description |
---|---|
static Object |
prototype
A reference to the prototype for a class of objects.
|
Modifier | Constructor and Description |
---|---|
|
Objs() |
|
Objs(Object value) |
protected |
Objs(Objs.Constructor<?> constructor,
Object js)
Constructor for auto-generated subclasses.
|
Modifier and Type | Method and Description |
---|---|
static <T> T |
$as(Class<T> clazz,
Object obj)
Casts given object to requested class.
|
static Objs |
$as(Object obj)
Casts given object to this class.
|
<T extends Objs> |
$cast(Class<T> clazz)
"Casts" this object to some other one.
|
Objs |
$delete(String k)
Removes a property for this JavaScript object.
|
Object |
$get(String n) |
static Object |
$js(Object obj)
Unwraps the object into plain JavaScript one.
|
Objs |
$set(String k,
Object n)
Sets a raw property on this JavaScript object.
|
static Object |
create(Object o)
Creates an object that has the specified prototype, and that optionally contains specified properties.
|
static Object |
create(Object o,
PropertyDescriptorMap properties)
Creates an object that has the specified prototype, and that optionally contains specified properties.
|
static Object |
defineProperties(Object o,
PropertyDescriptorMap properties)
Adds one or more properties to an object, and/or modifies attributes of existing properties.
|
static Object |
defineProperty(Object o,
String p,
PropertyDescriptor attributes)
Adds a property to an object, or modifies attributes of an existing property.
|
static <T> T |
freeze(T o)
Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
|
static PropertyDescriptor |
getOwnPropertyDescriptor(Object o,
String p)
Gets the own property descriptor of the specified object.
|
static String[] |
getOwnPropertyNames(Object o)
Returns the names of the own properties of an object.
|
static Object |
getPrototypeOf(Object o)
Returns the prototype of an object.
|
Boolean |
hasOwnProperty(String v)
Determines whether an object has a property with the specified name.
|
static Boolean |
isExtensible(Object o)
Returns a value that indicates whether new properties can be added to an object.
|
static Boolean |
isFrozen(Object o)
Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object.
|
Boolean |
isPrototypeOf(Object v)
Determines whether an object exists in another object's prototype chain.
|
static Boolean |
isSealed(Object o)
Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
|
static Array<String> |
keys(Object o)
Returns the names of the enumerable properties and methods of an object.
|
static Object |
newObject() |
static Object |
newObject(Object value) |
static <T> T |
preventExtensions(T o)
Prevents the addition of new properties to an object.
|
Boolean |
propertyIsEnumerable(String v)
Determines whether a specified property is enumerable.
|
static <T> T |
seal(T o)
Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
|
String |
toLocaleString()
Returns a date converted to a string using the current locale.
|
String |
toString()
Returns a string representation of an object.
|
Object |
valueOf()
Returns the primitive value of the specified object.
|
public static Object prototype
protected Objs(Objs.Constructor<?> constructor, Object js)
$as(java.lang.Object)
or $as(java.lang.Class, java.lang.Object)
.constructor
- constructor associated with this type
js
- any raw object to be wrapped by this instancepublic Objs(Object value)
public Objs()
public static Objs $as(Object obj)
obj
- any objectobj
objectpublic static <T> T $as(Class<T> clazz, Object obj)
T
- the type of requested objectclazz
- identification of the typeobj
- object to be convertedobj
objectClassCastException
- if the obj
cannot be cast to
the requested classpublic static Object $js(Object obj)
obj
- an object to unwrap - either subclass of Objs
or
plain JavaScript objectobj
onepublic <T extends Objs> T $cast(Class<T> clazz)
T
- type one requestsclazz
- requested classClassCastException
- if cast cannot be donepublic Objs $set(String k, Object n)
$set
method returns this
which can be useful for chaining
multiple calls:
Objs js = new Objs(). $set("firstName", "John"). $set("lastName", "Cleese");
k
- the name of the propertyn
- the value of the propertypublic Objs $delete(String k)
k
- the name of property to removepublic Boolean hasOwnProperty(String v)
v
- A property name.public Boolean isPrototypeOf(Object v)
v
- Another object whose prototype chain is to be checked.public Boolean propertyIsEnumerable(String v)
v
- A property name.public String toLocaleString()
public String toString()
public Object valueOf()
public static Object getPrototypeOf(Object o)
o
- The object that references the prototype.public static PropertyDescriptor getOwnPropertyDescriptor(Object o, String p)
o
- Object that contains the property.p
- Name of the property.public static String[] getOwnPropertyNames(Object o)
o
- Object that contains the own properties.public static Object create(Object o, PropertyDescriptorMap properties)
o
- Object to use as a prototype. May be nullproperties
- JavaScript object that contains one or more property descriptors.public static Object create(Object o)
o
- Object to use as a prototype. May be nullproperties
- JavaScript object that contains one or more property descriptors.public static Object defineProperty(Object o, String p, PropertyDescriptor attributes)
o
- Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object.p
- The property name.attributes
- Descriptor for the property. It can be for a data property or an accessor property.public static Object defineProperties(Object o, PropertyDescriptorMap properties)
o
- Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object.properties
- JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property.public static <T> T seal(T o)
o
- Object on which to lock the attributes.public static <T> T freeze(T o)
o
- Object on which to lock the attributes.public static <T> T preventExtensions(T o)
o
- Object to make non-extensible.public static Boolean isSealed(Object o)
o
- Object to test.public static Boolean isFrozen(Object o)
o
- Object to test.public static Boolean isExtensible(Object o)
o
- Object to test.public static Array<String> keys(Object o)
o
- Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.public static Object newObject()
Copyright © 2018. All rights reserved.