Package org.mozilla.javascript
Class NativeString
- java.lang.Object
-
- org.mozilla.javascript.ScriptableObject
-
- org.mozilla.javascript.IdScriptableObject
-
- org.mozilla.javascript.NativeString
-
- All Implemented Interfaces:
java.io.Serializable
,ConstProperties
,DebuggableObject
,IdFunctionCall
,Scriptable
,SymbolScriptable
final class NativeString extends IdScriptableObject
This class implements the String native object. See ECMA 15.5. String methods for dealing with regular expressions are ported directly from C. Latest port is from version 1.40.12.19 in the JSFUN13_BRANCH.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.mozilla.javascript.ScriptableObject
ScriptableObject.GetterSlot, ScriptableObject.KeyComparator, ScriptableObject.Slot, ScriptableObject.SlotAccess
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ConstructorId_charAt
private static int
ConstructorId_charCodeAt
private static int
ConstructorId_concat
private static int
ConstructorId_equalsIgnoreCase
private static int
ConstructorId_fromCharCode
private static int
ConstructorId_fromCodePoint
private static int
ConstructorId_indexOf
private static int
ConstructorId_lastIndexOf
private static int
ConstructorId_localeCompare
private static int
ConstructorId_match
private static int
ConstructorId_replace
private static int
ConstructorId_search
private static int
ConstructorId_slice
private static int
ConstructorId_split
private static int
ConstructorId_substr
private static int
ConstructorId_substring
private static int
ConstructorId_toLocaleLowerCase
private static int
ConstructorId_toLowerCase
private static int
ConstructorId_toUpperCase
private static int
Id_anchor
private static int
Id_big
private static int
Id_blink
private static int
Id_bold
private static int
Id_charAt
private static int
Id_charCodeAt
private static int
Id_codePointAt
private static int
Id_concat
private static int
Id_constructor
private static int
Id_endsWith
private static int
Id_equals
private static int
Id_equalsIgnoreCase
private static int
Id_fixed
private static int
Id_fontcolor
private static int
Id_fontsize
private static int
Id_includes
private static int
Id_indexOf
private static int
Id_italics
private static int
Id_lastIndexOf
private static int
Id_length
private static int
Id_link
private static int
Id_localeCompare
private static int
Id_match
private static int
Id_normalize
private static int
Id_padEnd
private static int
Id_padStart
private static int
Id_repeat
private static int
Id_replace
private static int
Id_search
private static int
Id_slice
private static int
Id_small
private static int
Id_split
private static int
Id_startsWith
private static int
Id_strike
private static int
Id_sub
private static int
Id_substr
private static int
Id_substring
private static int
Id_sup
private static int
Id_toLocaleLowerCase
private static int
Id_toLocaleUpperCase
private static int
Id_toLowerCase
private static int
Id_toSource
private static int
Id_toString
private static int
Id_toUpperCase
private static int
Id_trim
private static int
Id_trimEnd
private static int
Id_trimLeft
private static int
Id_trimRight
private static int
Id_trimStart
private static int
Id_valueOf
private static int
MAX_INSTANCE_ID
private static int
MAX_PROTOTYPE_ID
private static long
serialVersionUID
private java.lang.CharSequence
string
private static java.lang.Object
STRING_TAG
private static int
SymbolId_iterator
-
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
-
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
-
-
Constructor Summary
Constructors Constructor Description NativeString(java.lang.CharSequence s)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private ScriptableObject
defaultIndexPropertyDescriptor(java.lang.Object value)
java.lang.Object
execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
'thisObj' will be null if invoked as constructor, in which case instance of Scriptable should be returned.protected void
fillConstructorProperties(IdFunctionObject ctor)
protected int
findInstanceIdInfo(java.lang.String s)
Map name to id of instance property.protected int
findPrototypeId(java.lang.String s)
protected int
findPrototypeId(Symbol k)
java.lang.Object
get(int index, Scriptable start)
Returns the value of the indexed property or NOT_FOUND.int
getAttributes(int index)
Get the attributes of an indexed property.java.lang.String
getClassName()
Return the name of the class.protected java.lang.Object[]
getIds(boolean nonEnumerable, boolean getSymbols)
protected java.lang.String
getInstanceIdName(int id)
Map id back to property name it defines.protected java.lang.Object
getInstanceIdValue(int id)
Get id value.(package private) int
getLength()
protected int
getMaxInstanceId()
Get maximum id findInstanceIdInfo can generate.protected ScriptableObject
getOwnPropertyDescriptor(Context cx, java.lang.Object id)
boolean
has(int index, Scriptable start)
Returns true if the property index is defined.(package private) static void
init(Scriptable scope, boolean sealed)
protected void
initPrototypeId(int id)
private static java.lang.String
js_concat(java.lang.String target, java.lang.Object[] args)
private static int
js_indexOf(int methodId, java.lang.String target, java.lang.Object[] args)
private static int
js_lastIndexOf(java.lang.String target, java.lang.Object[] args)
private static java.lang.String
js_pad(Context cx, Scriptable thisObj, IdFunctionObject f, java.lang.Object[] args, boolean atStart)
private static java.lang.String
js_repeat(Context cx, Scriptable thisObj, IdFunctionObject f, java.lang.Object[] args)
private static java.lang.CharSequence
js_slice(java.lang.CharSequence target, java.lang.Object[] args)
private static java.lang.CharSequence
js_substr(java.lang.CharSequence target, java.lang.Object[] args)
private static java.lang.CharSequence
js_substring(Context cx, java.lang.CharSequence target, java.lang.Object[] args)
void
put(int index, Scriptable start, java.lang.Object value)
Sets the value of the indexed property, creating it if need be.private static NativeString
realThis(Scriptable thisObj, IdFunctionObject f)
private static java.lang.String
tagify(Scriptable thisObj, java.lang.String tag, java.lang.String attribute, java.lang.Object[] args)
java.lang.CharSequence
toCharSequence()
java.lang.String
toString()
-
Methods inherited from class org.mozilla.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, defineOwnProperty, delete, delete, exportAsJSClass, findInstanceIdInfo, get, get, getAttributes, getAttributes, has, has, hasPrototypeMap, incompatibleCallError, initPrototypeConstructor, initPrototypeMethod, initPrototypeMethod, initPrototypeMethod, initPrototypeValue, initPrototypeValue, instanceIdInfo, put, put, setAttributes, setInstanceIdAttributes, setInstanceIdValue
-
Methods inherited from class org.mozilla.javascript.ScriptableObject
addLazilyInitializedValue, applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildClassCtor, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, checkValidAttributes, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasInstance, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, putConst, putConstProperty, putProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
STRING_TAG
private static final java.lang.Object STRING_TAG
-
Id_length
private static final int Id_length
- See Also:
- Constant Field Values
-
MAX_INSTANCE_ID
private static final int MAX_INSTANCE_ID
- See Also:
- Constant Field Values
-
ConstructorId_fromCharCode
private static final int ConstructorId_fromCharCode
- See Also:
- Constant Field Values
-
ConstructorId_fromCodePoint
private static final int ConstructorId_fromCodePoint
- See Also:
- Constant Field Values
-
Id_constructor
private static final int Id_constructor
- See Also:
- Constant Field Values
-
Id_toString
private static final int Id_toString
- See Also:
- Constant Field Values
-
Id_toSource
private static final int Id_toSource
- See Also:
- Constant Field Values
-
Id_valueOf
private static final int Id_valueOf
- See Also:
- Constant Field Values
-
Id_charAt
private static final int Id_charAt
- See Also:
- Constant Field Values
-
Id_charCodeAt
private static final int Id_charCodeAt
- See Also:
- Constant Field Values
-
Id_indexOf
private static final int Id_indexOf
- See Also:
- Constant Field Values
-
Id_lastIndexOf
private static final int Id_lastIndexOf
- See Also:
- Constant Field Values
-
Id_split
private static final int Id_split
- See Also:
- Constant Field Values
-
Id_substring
private static final int Id_substring
- See Also:
- Constant Field Values
-
Id_toLowerCase
private static final int Id_toLowerCase
- See Also:
- Constant Field Values
-
Id_toUpperCase
private static final int Id_toUpperCase
- See Also:
- Constant Field Values
-
Id_substr
private static final int Id_substr
- See Also:
- Constant Field Values
-
Id_concat
private static final int Id_concat
- See Also:
- Constant Field Values
-
Id_slice
private static final int Id_slice
- See Also:
- Constant Field Values
-
Id_bold
private static final int Id_bold
- See Also:
- Constant Field Values
-
Id_italics
private static final int Id_italics
- See Also:
- Constant Field Values
-
Id_fixed
private static final int Id_fixed
- See Also:
- Constant Field Values
-
Id_strike
private static final int Id_strike
- See Also:
- Constant Field Values
-
Id_small
private static final int Id_small
- See Also:
- Constant Field Values
-
Id_big
private static final int Id_big
- See Also:
- Constant Field Values
-
Id_blink
private static final int Id_blink
- See Also:
- Constant Field Values
-
Id_sup
private static final int Id_sup
- See Also:
- Constant Field Values
-
Id_sub
private static final int Id_sub
- See Also:
- Constant Field Values
-
Id_fontsize
private static final int Id_fontsize
- See Also:
- Constant Field Values
-
Id_fontcolor
private static final int Id_fontcolor
- See Also:
- Constant Field Values
-
Id_link
private static final int Id_link
- See Also:
- Constant Field Values
-
Id_anchor
private static final int Id_anchor
- See Also:
- Constant Field Values
-
Id_equals
private static final int Id_equals
- See Also:
- Constant Field Values
-
Id_equalsIgnoreCase
private static final int Id_equalsIgnoreCase
- See Also:
- Constant Field Values
-
Id_match
private static final int Id_match
- See Also:
- Constant Field Values
-
Id_search
private static final int Id_search
- See Also:
- Constant Field Values
-
Id_replace
private static final int Id_replace
- See Also:
- Constant Field Values
-
Id_localeCompare
private static final int Id_localeCompare
- See Also:
- Constant Field Values
-
Id_toLocaleLowerCase
private static final int Id_toLocaleLowerCase
- See Also:
- Constant Field Values
-
Id_toLocaleUpperCase
private static final int Id_toLocaleUpperCase
- See Also:
- Constant Field Values
-
Id_trim
private static final int Id_trim
- See Also:
- Constant Field Values
-
Id_trimLeft
private static final int Id_trimLeft
- See Also:
- Constant Field Values
-
Id_trimRight
private static final int Id_trimRight
- See Also:
- Constant Field Values
-
Id_includes
private static final int Id_includes
- See Also:
- Constant Field Values
-
Id_startsWith
private static final int Id_startsWith
- See Also:
- Constant Field Values
-
Id_endsWith
private static final int Id_endsWith
- See Also:
- Constant Field Values
-
Id_normalize
private static final int Id_normalize
- See Also:
- Constant Field Values
-
Id_repeat
private static final int Id_repeat
- See Also:
- Constant Field Values
-
Id_codePointAt
private static final int Id_codePointAt
- See Also:
- Constant Field Values
-
Id_padStart
private static final int Id_padStart
- See Also:
- Constant Field Values
-
Id_padEnd
private static final int Id_padEnd
- See Also:
- Constant Field Values
-
SymbolId_iterator
private static final int SymbolId_iterator
- See Also:
- Constant Field Values
-
Id_trimStart
private static final int Id_trimStart
- See Also:
- Constant Field Values
-
Id_trimEnd
private static final int Id_trimEnd
- See Also:
- Constant Field Values
-
MAX_PROTOTYPE_ID
private static final int MAX_PROTOTYPE_ID
- See Also:
- Constant Field Values
-
ConstructorId_charAt
private static final int ConstructorId_charAt
- See Also:
- Constant Field Values
-
ConstructorId_charCodeAt
private static final int ConstructorId_charCodeAt
- See Also:
- Constant Field Values
-
ConstructorId_indexOf
private static final int ConstructorId_indexOf
- See Also:
- Constant Field Values
-
ConstructorId_lastIndexOf
private static final int ConstructorId_lastIndexOf
- See Also:
- Constant Field Values
-
ConstructorId_split
private static final int ConstructorId_split
- See Also:
- Constant Field Values
-
ConstructorId_substring
private static final int ConstructorId_substring
- See Also:
- Constant Field Values
-
ConstructorId_toLowerCase
private static final int ConstructorId_toLowerCase
- See Also:
- Constant Field Values
-
ConstructorId_toUpperCase
private static final int ConstructorId_toUpperCase
- See Also:
- Constant Field Values
-
ConstructorId_substr
private static final int ConstructorId_substr
- See Also:
- Constant Field Values
-
ConstructorId_concat
private static final int ConstructorId_concat
- See Also:
- Constant Field Values
-
ConstructorId_slice
private static final int ConstructorId_slice
- See Also:
- Constant Field Values
-
ConstructorId_equalsIgnoreCase
private static final int ConstructorId_equalsIgnoreCase
- See Also:
- Constant Field Values
-
ConstructorId_match
private static final int ConstructorId_match
- See Also:
- Constant Field Values
-
ConstructorId_search
private static final int ConstructorId_search
- See Also:
- Constant Field Values
-
ConstructorId_replace
private static final int ConstructorId_replace
- See Also:
- Constant Field Values
-
ConstructorId_localeCompare
private static final int ConstructorId_localeCompare
- See Also:
- Constant Field Values
-
ConstructorId_toLocaleLowerCase
private static final int ConstructorId_toLocaleLowerCase
- See Also:
- Constant Field Values
-
string
private java.lang.CharSequence string
-
-
Method Detail
-
init
static void init(Scriptable scope, boolean sealed)
-
getClassName
public java.lang.String getClassName()
Description copied from class:ScriptableObject
Return the name of the class. This is typically the same name as the constructor. Classes extending ScriptableObject must implement this abstract method.- Specified by:
getClassName
in interfaceScriptable
- Specified by:
getClassName
in classScriptableObject
-
getMaxInstanceId
protected int getMaxInstanceId()
Description copied from class:IdScriptableObject
Get maximum id findInstanceIdInfo can generate.- Overrides:
getMaxInstanceId
in classIdScriptableObject
-
findInstanceIdInfo
protected int findInstanceIdInfo(java.lang.String s)
Description copied from class:IdScriptableObject
Map name to id of instance property. Should return 0 if not found or the result ofIdScriptableObject.instanceIdInfo(int, int)
.- Overrides:
findInstanceIdInfo
in classIdScriptableObject
-
getInstanceIdName
protected java.lang.String getInstanceIdName(int id)
Description copied from class:IdScriptableObject
Map id back to property name it defines.- Overrides:
getInstanceIdName
in classIdScriptableObject
-
getInstanceIdValue
protected java.lang.Object getInstanceIdValue(int id)
Description copied from class:IdScriptableObject
Get id value. If id value is constant, descendant can call cacheIdValue to store value in the permanent cache. Default implementation creates IdFunctionObject instance for given id and cache its value- Overrides:
getInstanceIdValue
in classIdScriptableObject
-
fillConstructorProperties
protected void fillConstructorProperties(IdFunctionObject ctor)
- Overrides:
fillConstructorProperties
in classIdScriptableObject
-
initPrototypeId
protected void initPrototypeId(int id)
- Overrides:
initPrototypeId
in classIdScriptableObject
-
execIdCall
public java.lang.Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
Description copied from class:IdScriptableObject
'thisObj' will be null if invoked as constructor, in which case instance of Scriptable should be returned.- Specified by:
execIdCall
in interfaceIdFunctionCall
- Overrides:
execIdCall
in classIdScriptableObject
-
realThis
private static NativeString realThis(Scriptable thisObj, IdFunctionObject f)
-
tagify
private static java.lang.String tagify(Scriptable thisObj, java.lang.String tag, java.lang.String attribute, java.lang.Object[] args)
-
toCharSequence
public java.lang.CharSequence toCharSequence()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
get
public java.lang.Object get(int index, Scriptable start)
Description copied from class:ScriptableObject
Returns the value of the indexed property or NOT_FOUND.- Specified by:
get
in interfaceScriptable
- Overrides:
get
in classScriptableObject
- Parameters:
index
- the numeric index for the propertystart
- the object in which the lookup began- Returns:
- the value of the property (may be null), or NOT_FOUND
- See Also:
Scriptable.get(String,Scriptable)
-
put
public void put(int index, Scriptable start, java.lang.Object value)
Description copied from class:ScriptableObject
Sets the value of the indexed property, creating it if need be.- Specified by:
put
in interfaceScriptable
- Overrides:
put
in classScriptableObject
- Parameters:
index
- the numeric index for the propertystart
- the object whose property is being setvalue
- value to set the property to- See Also:
Scriptable.has(int, Scriptable)
,Scriptable.get(int, Scriptable)
,ScriptableObject.putProperty(Scriptable, int, Object)
,Context.toObject(Object, Scriptable)
-
has
public boolean has(int index, Scriptable start)
Description copied from class:ScriptableObject
Returns true if the property index is defined.- Specified by:
has
in interfaceScriptable
- Overrides:
has
in classScriptableObject
- Parameters:
index
- the numeric index for the propertystart
- the object in which the lookup began- Returns:
- true if and only if the property was found in the object
- See Also:
Scriptable.get(int, Scriptable)
,ScriptableObject.getProperty(Scriptable, int)
-
getAttributes
public int getAttributes(int index)
Description copied from class:ScriptableObject
Get the attributes of an indexed property.- Overrides:
getAttributes
in classScriptableObject
- Parameters:
index
- the numeric index for the property- Returns:
- the bitset of attributes
- See Also:
ScriptableObject.has(String, Scriptable)
,ScriptableObject.READONLY
,ScriptableObject.DONTENUM
,ScriptableObject.PERMANENT
,ScriptableObject.EMPTY
-
getIds
protected java.lang.Object[] getIds(boolean nonEnumerable, boolean getSymbols)
- Overrides:
getIds
in classIdScriptableObject
-
getOwnPropertyDescriptor
protected ScriptableObject getOwnPropertyDescriptor(Context cx, java.lang.Object id)
- Overrides:
getOwnPropertyDescriptor
in classIdScriptableObject
-
defaultIndexPropertyDescriptor
private ScriptableObject defaultIndexPropertyDescriptor(java.lang.Object value)
-
js_indexOf
private static int js_indexOf(int methodId, java.lang.String target, java.lang.Object[] args)
-
js_lastIndexOf
private static int js_lastIndexOf(java.lang.String target, java.lang.Object[] args)
-
js_substring
private static java.lang.CharSequence js_substring(Context cx, java.lang.CharSequence target, java.lang.Object[] args)
-
getLength
int getLength()
-
js_substr
private static java.lang.CharSequence js_substr(java.lang.CharSequence target, java.lang.Object[] args)
-
js_concat
private static java.lang.String js_concat(java.lang.String target, java.lang.Object[] args)
-
js_slice
private static java.lang.CharSequence js_slice(java.lang.CharSequence target, java.lang.Object[] args)
-
js_repeat
private static java.lang.String js_repeat(Context cx, Scriptable thisObj, IdFunctionObject f, java.lang.Object[] args)
-
js_pad
private static java.lang.String js_pad(Context cx, Scriptable thisObj, IdFunctionObject f, java.lang.Object[] args, boolean atStart)
-
findPrototypeId
protected int findPrototypeId(Symbol k)
- Overrides:
findPrototypeId
in classIdScriptableObject
-
findPrototypeId
protected int findPrototypeId(java.lang.String s)
- Overrides:
findPrototypeId
in classIdScriptableObject
-
-