001: /*
002: ItsNat Java Web Application Framework
003: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004: Author: Jose Maria Arranz Santamaria
005:
006: This program is free software: you can redistribute it and/or modify
007: it under the terms of the GNU Affero General Public License as published by
008: the Free Software Foundation, either version 3 of the License, or
009: (at your option) any later version. See the GNU Affero General Public
010: License for more details. See the copy of the GNU Affero General Public License
011: included in this program. If not, see <http://www.gnu.org/licenses/>.
012: */
013:
014: package org.itsnat.core.script;
015:
016: /**
017: * Encapsulates a JavaScript expression used to generate JavaScript code to send the client.
018: *
019: * <p>If the expression have properties or methods this interface provides methods
020: * to generate JavaScript code to access or call them.</p>
021: *
022: * @see ScriptUtil#createScriptExpr(Object)
023: */
024: public interface ScriptExpr {
025: /**
026: * Returns the JavaScript code of this expression.
027: *
028: * <p>The specified object is converted to JavaScript following the rules
029: * of {@link ScriptUtil#toScript(Object)} with an exception: if a <code>String</code> the
030: * content is not converted to a JavaScript string literal.
031: *
032: * @return the JavaScript code.
033: */
034: public String getCode();
035:
036: /**
037: * Generates the JavaScript code to set a value to the specified property of the result of this expression.
038: *
039: * @param propName property name.
040: * @param value the value to set. Is converted to JavaScript calling {@link ScriptUtil#toScript(Object)}.
041: * @param endSentence if true adds a ; at the end.
042: * @return the JavaScript code.
043: * @see ScriptUtil#getSetPropertyCode(Object,String,Object,boolean)
044: */
045: public String getSetPropertyCode(String propName, Object value,
046: boolean endSentence);
047:
048: /**
049: * Generates the JavaScript code to set a value to the specified property of the result of this expression.
050: *
051: * @param propName property name.
052: * @param value the value to set. Is converted to JavaScript calling {@link ScriptUtil#toScript(Object)}.
053: * @return the JavaScript code.
054: * @see ScriptUtil#getSetPropertyCode(Object,String,Object)
055: */
056: public String getSetPropertyCode(String propName, Object value);
057:
058: /**
059: * Generates the JavaScript code to get the value of the specified property of the result of this expression.
060: *
061: * @param propName property name.
062: * @param endSentence if true adds a ; at the end.
063: * @return the JavaScript code.
064: * @see ScriptUtil#getGetPropertyCode(Object,String,boolean)
065: */
066: public String getGetPropertyCode(String propName,
067: boolean endSentence);
068:
069: /**
070: * Generates the JavaScript code to get the value of the specified property of the result of this expression.
071: *
072: * @param propName property name.
073: * @return the JavaScript code.
074: * @see ScriptUtil#getGetPropertyCode(Object,String)
075: */
076: public String getGetPropertyCode(String propName);
077:
078: /**
079: * Generates the JavaScript code to call the specified method of the result of this expression.
080: *
081: * @param methodName method name.
082: * @param params the parameter list. Are converted to JavaScript calling {@link ScriptUtil#toScript(Object)}.
083: * @param endSentence if true adds a ; at the end.
084: * @return the JavaScript code.
085: * @see ScriptUtil#getCallMethodCode(Object,String,Object[],boolean)
086: */
087: public String getCallMethodCode(String methodName, Object[] params,
088: boolean endSentence);
089:
090: /**
091: * Generates the JavaScript code to call the specified method of the result of this expression.
092: *
093: * @param methodName method name.
094: * @param params the parameter list. Are converted to JavaScript calling {@link ScriptUtil#toScript(Object)}.
095: * @return the JavaScript code.
096: * @see ScriptUtil#getCallMethodCode(Object,String,Object[])
097: */
098: public String getCallMethodCode(String methodName, Object[] params);
099:
100: }
|