com.google.caja.parser.js
Class ObjectConstructor

java.lang.Object
  extended by com.google.caja.parser.AbstractParseTreeNode
      extended by com.google.caja.parser.js.AbstractExpression
          extended by com.google.caja.parser.js.ObjectConstructor
All Implemented Interfaces:
Expression, JsonMLCompatible, MutableParseTreeNode, ParseTreeNode, MessagePart, Renderable, java.lang.Cloneable

public final class ObjectConstructor
extends AbstractExpression

Sometimes called an object literal, a shorthand for constructing an object with a declared set of properties. I avoid the term object literal since every time the expression is evaluated, it results in a new object, and subexpressions need not be literal.

E.g. { x: 0, y : 1 }

Author:
mikesamuel@gmail.com

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.google.caja.parser.MutableParseTreeNode
MutableParseTreeNode.Mutation
 
Nested classes/interfaces inherited from interface com.google.caja.parser.ParseTreeNode
ParseTreeNode.ReflectiveCtor
 
Nested classes/interfaces inherited from interface com.google.caja.reporting.MessagePart
MessagePart.Factory
 
Nested classes/interfaces inherited from interface com.google.caja.parser.js.JsonMLCompatible
JsonMLCompatible.JsonMLBuilder
 
Field Summary
 
Fields inherited from interface com.google.caja.parser.ParseTreeNode
TAINTED
 
Constructor Summary
ObjectConstructor(FilePosition pos)
           
ObjectConstructor(FilePosition pos, java.util.List<? extends ObjProperty> properties)
           
ObjectConstructor(FilePosition pos, java.lang.Void value, java.util.List<? extends ObjProperty> properties)
           
 
Method Summary
 java.util.List<? extends ObjProperty> children()
          An immutable list of children.
protected  void childrenChanged()
          Called to perform consistency checks on the child list after changes have been made.
 java.lang.Boolean conditionResult()
          Returns the result of evaluating the expression in a boolean context or null if indeterminable.
 java.lang.Object getValue()
           
 ObjProperty propertyWithName(java.lang.String key)
           
 void render(RenderContext rc)
          Output the textual form to r.getOut().
 com.google.javascript.jscomp.jsonml.JsonML toJsonML()
          Creates a JsonML representation of this AST.
 java.lang.String typeOf()
          null or the result of applying the typeof operator to the result of this expression.
 
Methods inherited from class com.google.caja.parser.js.AbstractExpression
fold, isLeftHandSide, makeRenderer, simplifyForSideEffect
 
Methods inherited from class com.google.caja.parser.AbstractParseTreeNode
acceptPostOrder, acceptPreOrder, appendChild, childrenAs, childrenPart, clone, createMutation, equals, format, formatSelf, formatTree, formatTree, getAttributes, getComments, getFilePosition, hashCode, insertBefore, removeChild, replaceChild, setComments, setFilePosition, toString, toStringDeep, toStringDeep
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.caja.parser.MutableParseTreeNode
acceptPostOrder, acceptPreOrder, appendChild, createMutation, insertBefore, removeChild, replaceChild
 
Methods inherited from interface com.google.caja.parser.ParseTreeNode
clone, formatTree, getAttributes, getComments, getFilePosition
 
Methods inherited from interface com.google.caja.reporting.MessagePart
format
 

Constructor Detail

ObjectConstructor

@ParseTreeNode.ReflectiveCtor
public ObjectConstructor(FilePosition pos,
                                                      java.lang.Void value,
                                                      java.util.List<? extends ObjProperty> properties)
Parameters:
value - unused. This ctor is provided for reflection.

ObjectConstructor

public ObjectConstructor(FilePosition pos,
                         java.util.List<? extends ObjProperty> properties)

ObjectConstructor

public ObjectConstructor(FilePosition pos)
Method Detail

childrenChanged

protected void childrenChanged()
Description copied from class: AbstractParseTreeNode
Called to perform consistency checks on the child list after changes have been made. This can be overridden to do additional checks by subclasses, and to update derived state, but all subclasses must chain to super after performing their own checks.

This method may throw any RuntimeException on an invalid child. TODO(mikesamuel): maybe reliably throw an exception type, that includes information about the troublesome node.

Overrides:
childrenChanged in class AbstractParseTreeNode

getValue

public java.lang.Object getValue()
Specified by:
getValue in interface ParseTreeNode
Specified by:
getValue in class AbstractParseTreeNode
Returns:
null or a value with subclass specific meaning which encapsulates all parsed state separate from the children.

children

public java.util.List<? extends ObjProperty> children()
Description copied from interface: ParseTreeNode
An immutable list of children.

Specified by:
children in interface ParseTreeNode
Overrides:
children in class AbstractParseTreeNode

propertyWithName

public ObjProperty propertyWithName(java.lang.String key)

conditionResult

public java.lang.Boolean conditionResult()
Description copied from interface: Expression
Returns the result of evaluating the expression in a boolean context or null if indeterminable. This result is valid assuming that the expression does not throw an exception. If the expression provably always throws an exception, then it may return any result.

Specified by:
conditionResult in interface Expression
Overrides:
conditionResult in class AbstractExpression

render

public void render(RenderContext rc)
Description copied from interface: Renderable
Output the textual form to r.getOut().


typeOf

public java.lang.String typeOf()
Description copied from interface: Expression
null or the result of applying the typeof operator to the result of this expression.

Returns:
if the expression yields a result with the same typeof in all environments in which it returns normally, then returns the result of applying the typeof operator to the result. null if the type cannot be determined. This method is conservative, so it may return null where it is possible to prove a bound.

toJsonML

public com.google.javascript.jscomp.jsonml.JsonML toJsonML()
Description copied from interface: JsonMLCompatible
Creates a JsonML representation of this AST.



Copyright (C) 2008 Google Inc.
Licensed under the Apache License, Version 2.0