You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2006/10/06 17:36:50 UTC
svn commit: r453699 - in /incubator/xap/trunk/src/xap/data: ./ bridge/
controller/ formatter/
Author: mturyn
Date: Fri Oct 6 10:36:49 2006
New Revision: 453699
URL: http://svn.apache.org/viewvc?view=rev&rev=453699
Log:
Re-introduced support for formatters, implemented a stupid decimal formatter. Formatting chaining not yet up.
Added:
incubator/xap/trunk/src/xap/data/formatter/FormatterChain.js (with props)
incubator/xap/trunk/src/xap/data/formatter/FormatterContainerImpl.js
incubator/xap/trunk/src/xap/data/formatter/JsFormatterImpl.js
Modified:
incubator/xap/trunk/src/xap/data/DataFramework.js
incubator/xap/trunk/src/xap/data/DataNamespaceHandler.js
incubator/xap/trunk/src/xap/data/DataServiceImpl.js
incubator/xap/trunk/src/xap/data/bridge/BindingBridge.js
incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js
incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js
incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js
incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js
incubator/xap/trunk/src/xap/data/bridge/SimpleDocumentDataSourceBridge.js
incubator/xap/trunk/src/xap/data/controller/Binding.js
incubator/xap/trunk/src/xap/data/controller/BindingResolver.js
incubator/xap/trunk/src/xap/data/controller/DataControllerException.js
Modified: incubator/xap/trunk/src/xap/data/DataFramework.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/DataFramework.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/DataFramework.js (original)
+++ incubator/xap/trunk/src/xap/data/DataFramework.js Fri Oct 6 10:36:49 2006
@@ -34,9 +34,9 @@
Xap.require("xap.data.datasource.DataSourceContainerImpl") ;
// Xap.require("xap.data.datasource.MalformedQueryException") ;
// Xap.require("xap.data.datasource.UnsupportedBindingTypeException") ;
-// Xap.require("xap.data.formatter.FormatterContainer") ;
-// Xap.require("xap.data.formatter.FormatterContainerImpl") ;
-// Xap.require("xap.util.EscapeSyntaxException") ;
+Xap.require("xap.data.formatter.FormatterContainerImpl") ;
+Xap.require("xap.util.EscapeSyntaxException") ;
+
/**
* This class encapsulates all the data primitives available for a client session.
* It may be used to lookup bindings, formatters, data sources, and validators.
@@ -57,8 +57,7 @@
this._bindingContainer = new xap.data.controller.BindingContainerImpl(sess);
// TODO: use the appropriate containers---just
// placeholders here to avoid follow-on errors.
- this._formatterContainer = new xap.data.datasource.DataSourceContainerImpl(sess);
- // new FormatterContainerImpl(sess);
+ this._formatterContainer = new xap.data.formatter.FormatterContainerImpl(sess);
this._iteratorContainer = new xap.data.controller.IteratorContainerImpl(sess);
//add the dataSourceContainer to the container of containers
Modified: incubator/xap/trunk/src/xap/data/DataNamespaceHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/DataNamespaceHandler.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/DataNamespaceHandler.js (original)
+++ incubator/xap/trunk/src/xap/data/DataNamespaceHandler.js Fri Oct 6 10:36:49 2006
@@ -94,7 +94,11 @@
//the names of the documents to create and make plug-in aware
/*private static final String[]*/
-xap.data.DataNamespaceHandler.DOCUMENT_NAMES = [xap.data.DataNamespaceHandler.BINDING_DOCUMENT, xap.data.DataNamespaceHandler.DATA_SOURCES_DOCUMENT, xap.data.DataNamespaceHandler.FORMATTERS_DOCUMENT];
+xap.data.DataNamespaceHandler.DOCUMENT_NAMES = [
+ xap.data.DataNamespaceHandler.BINDING_DOCUMENT,
+ xap.data.DataNamespaceHandler.DATA_SOURCES_DOCUMENT,
+ xap.data.DataNamespaceHandler.FORMATTERS_DOCUMENT
+ ];
xap.data.DataNamespaceHandler.s_log = xap.util.LogFactory.getLog("xap.data.DataNamespaceHandler");
/**
* @private {ClientSession}
@@ -185,7 +189,7 @@
//we found a definition matching the tag name, namespace
//and data doc name, so we are good to go
- if (definition != null) {
+ if ((typeof definition != "undefined") && (definition != null)) {
// In the absence of a separate document registry:
/*Document*/
var destinationDocument = this._session.getDocumentContainer().get(currentDocumentName);
@@ -206,6 +210,6 @@
//an error
//TODO: fix exception handling
var ex = new xap.util.Exception("UNHANDLED_TAG_IN_NAMESPACE" + ": " + element.getNamespaceUri() + ", " + element.getLocalName()) ;
- clientSession.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE+ex,ex);
+ clientSession.handleException(xap.data.DataFramework.DATA_FRAMEWORK_EXCEPTION_TYPE + ex,ex);
};
Modified: incubator/xap/trunk/src/xap/data/DataServiceImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/DataServiceImpl.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/DataServiceImpl.js (original)
+++ incubator/xap/trunk/src/xap/data/DataServiceImpl.js Fri Oct 6 10:36:49 2006
@@ -16,15 +16,15 @@
*/
-//Xap.require("xap.ExceptionContext;")
-//Xap.require("xap.data.controller.Binding;")
-//Xap.require("xap.data.controller.DataControllerException;")
-//Xap.require("xap.data.datasource.DataAccessException;")
-//Xap.require("xap.data.datasource.DataSourceContainer;")
-//Xap.require("xap.data.datasource.MalformedQueryException;")
-//Xap.require("xap.data.datasource.UnsupportedBindingTypeException;")
-//Xap.require("xap.data.formatter.FormatterContainer;")
-//Xap.require("xap.util.EscapeSyntaxException;")
+//Xap.require("xap.ExceptionContext") ;
+//Xap.require("xap.data.controller.Binding") ;
+//Xap.require("xap.data.controller.DataControllerException") ;
+//Xap.require("xap.data.datasource.DataAccessException") ;
+//Xap.require("xap.data.datasource.DataSourceContainer") ;
+//Xap.require("xap.data.datasource.MalformedQueryException") ;
+//Xap.require("xap.data.datasource.UnsupportedBindingTypeException") ;
+Xap.require("xap.data.formatter.FormatterContainerImpl") ;
+Xap.require("xap.util.EscapeSyntaxException") ;
/**
* The data service is used to gain programatic access to the stored
* formatter and data source definitions.
Modified: incubator/xap/trunk/src/xap/data/bridge/BindingBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/BindingBridge.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/BindingBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/BindingBridge.js Fri Oct 6 10:36:49 2006
@@ -22,7 +22,7 @@
Xap.require("xap.data.controller.Binding");
Xap.require("xap.data.controller.BindingType");
Xap.require("xap.data.datasource.DataSourceImpl");
-//Xap.require("xap.data.formatter.Formatter");
+Xap.require("xap.data.formatter.JsFormatterImpl");
Xap.require("xap.xml.dom.XapElement");
Xap.require("xap.data.XmlDataTokens") ;
Xap.require("xap.data.bridge.DataAttributeConverter") ;
@@ -90,10 +90,10 @@
}
//if we got to this point OK, add the formatter
-//TODO IMPORTANT turn formatter on when we have one.
-// if (binding!=null){
-// this.addFormatters(formatter,binding);
-// }
+
+ if (binding!=null){
+ this.addFormatters(formatter,binding);
+ }
};
/**
* @private
@@ -111,7 +111,7 @@
//and add it to the binding
try {
/*Formatter*/
- var f = xap.data.DataAQttributeConverter.toFormatter(formatter, this.getDataService());
+ var f = xap.data.bridge.DataAttributeConverter.toFormatter(formatter, this.getDataService());
binding.setFormatter(f);
}
catch (e) { //AttributeConversionException
Modified: incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DataAttributeConverter.js Fri Oct 6 10:36:49 2006
@@ -22,17 +22,17 @@
Xap.require("xap.data.controller.BindingType");
Xap.require("xap.data.datasource.DataSourceImpl");
Xap.require("xap.data.XmlDataTokens");
+Xap.require("xap.data.formatter.JsFormatterImpl")
xap.data.bridge.DataAttributeConverter = function(){
} ;
-// TODO: turn this back on when
-//Xap.require("xap.data.formatter.Formatter")
-// Only static methods, no need here:
+
+// Only static methods, no subclasses, so no need here:
//Xap.setupClassAsSubclassOf("xap.data.bridge.DataAttributeConverter", "xap.taghandling.AttributeConverter");
/**
* @public
@@ -133,7 +133,9 @@
country = s.substring(iof + 1);
s = s.substring(0, iof);
}
- return new Locale(s, country);
+ //return new Locale(s, country);
+ // TODO: something real?
+ return {s:s, country:country} ;
}
catch (e) { //Exception
throw new xap.taghandling.AttributeConversionException(s, "locale", e);
Modified: incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DataFrameworkBridge.js Fri Oct 6 10:36:49 2006
@@ -18,8 +18,8 @@
Xap.require("xap.taghandling.AbstractTagImpl");
Xap.require("xap.data.DataServiceImpl");
Xap.require("xap.data.DataServiceFactory");
-//Xap.require("xap.data.datasource.DataSourceContainer") ;
-//Xap.require("xap.data.formatter.FormatterContainer") ;
+Xap.require("xap.data.datasource.DataSourceContainerImpl") ;
+Xap.require("xap.data.formatter.FormatterContainerImpl") ;
Xap.require("xap.util.LogFactory");
/**
* The base class for all data framework tags, provides convenience methods
@@ -53,7 +53,10 @@
/*public void*/
xap.data.bridge.DataFrameworkBridge.prototype.init = function () {
//this.getClass().getName()
- this.getLog().debug("xap.data.bridge.DataFrameworkBridge" + " got element: " + this.getElement());
+ this.getLog().debug("xap.data.bridge.DataFrameworkBridge"
+ + " got element: "
+ + this.getElement()
+ );
};
//-----------------------------------------------------------------------
Modified: incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/DataSourceBridge.js Fri Oct 6 10:36:49 2006
@@ -154,7 +154,7 @@
var dataSource = null;
try {
dataSource = new xap.data.datasource.DataSourceImpl();
- // DataAttributeConverter.toClassInstance(
+ // xap.data.bridge.DataAttributeConverter.toClassInstance(
// className, DataSource.class)
}
catch (e) {
Modified: incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/ObjectDataSourceBridge.js Fri Oct 6 10:36:49 2006
@@ -39,9 +39,9 @@
* @author ikaplansky
*/
xap.data.bridge.ObjectDataSourceBridge = function () {
- alert("ObjectDataSourceBridge() start") ;
+// alert("ObjectDataSourceBridge() start") ;
xap.data.bridge.DataSourceBridge.call(this) ;
- alert("ObjectDataSourceBridge() end") ;
+// alert("ObjectDataSourceBridge() end") ;
};
Xap.setupClassAsSubclassOf("xap.data.bridge.ObjectDataSourceBridge","xap.data.bridge.DataSourceBridge") ;
Modified: incubator/xap/trunk/src/xap/data/bridge/SimpleDocumentDataSourceBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/bridge/SimpleDocumentDataSourceBridge.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/bridge/SimpleDocumentDataSourceBridge.js (original)
+++ incubator/xap/trunk/src/xap/data/bridge/SimpleDocumentDataSourceBridge.js Fri Oct 6 10:36:49 2006
@@ -30,7 +30,7 @@
// /Xap.require("xap.util.ResourceDictionary") ;
Xap.require("xap.xml.dom.XapElement");
Xap.require("xap.data.bridge.DataSourceBridge");
-Xap.require("xap.data.XmlDataTokens");
+Xap.require("xap.data.bridge.XmlDataTokens");
/**
* SimpleDocumentDataSourceBridge is a simplified bridge class for the
* documentDataSource tag,
@@ -57,7 +57,7 @@
dataSource = new xap.data.datasource.SimpleDocumentDataSource(this, uri);
}
catch (e) { //AttributeConversionException
-// this.reportInvalidXmlException( xap.data.XmlDataTokens.CLASS, className,
+// this.reportInvalidXmlException( xap.data.bridge.XmlDataTokens.CLASS, className,
// this.getElement(), e );
// TODO: Restore better exception handling
throw new xap.util.XapException("Error creating a SimpleDocumentDataSource instance:\n" + e);
Modified: incubator/xap/trunk/src/xap/data/controller/Binding.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/Binding.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/Binding.js (original)
+++ incubator/xap/trunk/src/xap/data/controller/Binding.js Fri Oct 6 10:36:49 2006
@@ -28,7 +28,7 @@
//Xap.require("xap.data.datasource.MalformedQueryException") ;
//Xap.require("xap.data.datasource.UnsupportedBindingTypeException") ;
//Xap.require("xap.data.formatter.FormatException") ;
-//Xap.require("xap.data.formatter.Formatter") ;
+Xap.require("xap.data.formatter.JsFormatterImpl") ;
//Xap.require("xap.util.TypeConversionException") ;
Xap.require("xap.xml.dom.XapElement");
Xap.require("xap.data.controller.BindingType");
@@ -369,8 +369,8 @@
if (data != null) {
try {
// TODO at least get the formatting back in:
-// this._currentValue = this.getSession().getTypeConversionService().convertToString(formatObject(data));
- this._currentValue = "" + data;
+ this._currentValue = "" + this.formatObject(data) ;
+// this._currentValue = "" + data;
}
catch (dataException) { //DataException
this._session.handleException(xap.data.DataServiceImpl.DATA_FRAMEWORK_EXCEPTION_TYPE + ": no data retrieved: "+dataException, dataException);
Modified: incubator/xap/trunk/src/xap/data/controller/BindingResolver.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/BindingResolver.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/BindingResolver.js (original)
+++ incubator/xap/trunk/src/xap/data/controller/BindingResolver.js Fri Oct 6 10:36:49 2006
@@ -20,7 +20,7 @@
Xap.require("xap.data.DataFramework");
Xap.require("xap.data.DataServiceImpl");
Xap.require("xap.data.bridge.XmlDataTokens");
-//Xap.require("xap.data.formatter.Formatter") ;
+//Xap.require("xap.data.formatter.JsFormatterImpl") ;
//Xap.require("xap.util.EscapeSyntaxException") ;
Xap.require("xap.util.EscapeSyntaxParser") ;
Xap.require("xap.data.controller.ContextStack") ;
Modified: incubator/xap/trunk/src/xap/data/controller/DataControllerException.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/controller/DataControllerException.js?view=diff&rev=453699&r1=453698&r2=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/controller/DataControllerException.js (original)
+++ incubator/xap/trunk/src/xap/data/controller/DataControllerException.js Fri Oct 6 10:36:49 2006
@@ -17,14 +17,14 @@
*
* @param msgId{String}
**/
-xap.data.controller.DataControllerException.prototype. = function( msgId ) {
+xap.data.controller.DataControllerException = function( msgId ) {
super( msgId );
}
- /**
- * @see DataException#DataException(String, String[], Locale)
- *
+/**
+ * @see DataException#DataException(String, String[], Locale)
+ *
* @public
* @return {DataControllerException}
*
Added: incubator/xap/trunk/src/xap/data/formatter/FormatterChain.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/formatter/FormatterChain.js?view=auto&rev=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/formatter/FormatterChain.js (added)
+++ incubator/xap/trunk/src/xap/data/formatter/FormatterChain.js Fri Oct 6 10:36:49 2006
@@ -0,0 +1,215 @@
+
+Xap.require("xap.session.ClientSession") ;
+Xap.require("xap.data.InitializationException") ;
+//Xap.require("xap.util.Log") ;
+Xap.require("xap.util.LogFactory") ;
+Xap.require("xap.util.ResourceDictionary") ;
+Xap.require("xap.xml.dom.XapElement") ;
+
+/**
+ * FormatterChain is a chain of formatters that are executed in order.
+ *
+ * <p/>
+ *
+ * The output of a previous Formatter is used as input to the next one in the
+ * chain. Here is an example of how to declare a formatter chain: <br/><br/>
+ *
+ * <data:formatterChain id="formatterChain1"
+ * xmlns="http://nexaweb.com/data"><br/>
+ * <data:formatterReference formatter="formatter1"
+ * xmlns="http://nexaweb.com/data"/><br/>
+ * <data:formatterReference formatter="formatter2"
+ * xmlns="http://nexaweb.com/data"/><br/>
+ * <data:formatterReference formatter="formatter3"
+ * xmlns="http://nexaweb.com/data"/><br/>
+ * </data:formatterChain> <br><br>
+ *
+ * In the above example a formatterChain is declared that consists of 3
+ * formatters: "formatter1", "formatter2" and "formatter3" which are the ids of
+ * previously declared formatters. The formatterChain's id can be used in any
+ * place a formatter id is expected.
+ *
+ * @version $Revision: 1.4 $
+ * @author ikaplansky
+ */
+Xap.provide("xap.data.formatter.FormatterChain") ;
+Xap.setupClassAsSubclassOf("xap.data.formatter.FormatterChain","Formatter") ;
+
+ //-----------------------------------------------------------------------
+ // Constants.
+ //-----------------------------------------------------------------------
+ // {0} formatter.toString()
+ /*private static final String*/
+xap.data.formatter.FormatterChain.FORMATTER_INSTANCE_ALREADY_IN_CHAIN_MSGID =
+ "formatterAlreadyInChain";
+ /*private static final String*/
+xap.data.formatter.FormatterChain.NULL_FORMATTER_MSGID = "nullFormatter";
+
+
+ //-----------------------------------------------------------------------
+ // Instance Variables.
+ //-----------------------------------------------------------------------
+ // contains the chain of formatters that will be applied in order to the
+ // argument of the format(Object) method.
+/**
+ * @private Vector
+**/
+xap.data.formatter.FormatterChain.prototype._formatters = null;
+
+ //-----------------------------------------------------------------------
+ // Constructors.
+ //-----------------------------------------------------------------------
+
+ public FormatterChain() {
+ // for use by reflection
+ }
+
+ //-----------------------------------------------------------------------
+ // Formatter Interface.
+ //-----------------------------------------------------------------------
+
+ /**
+ * @see Formatter#initialize(String, ClientSession, Element)
+ *
+ * @public
+ * @return {void}
+**/
+xap.data.formatter.FormatterChain.prototype.initialize = function( String id, ClientSession session,
+ Element formatterElement ) {
+ * @throws InitializationException
+ this._formatters = new Array(0) ;
+ }
+
+ /**
+ * @see Formatter#format(Object)
+ *
+ * @public
+ * @return {Object}
+**/
+xap.data.formatter.FormatterChain.prototype.format = function( Object object ) throws FormatException {
+ /*Object*/
+var formattedObject = object;
+ for( int i=0; i < this._formatters.size(); i++ ) {
+ /*Formatter*/
+var f = (Formatter) this._formatters.elementAt( i );
+ formattedObject = f.format( formattedObject );
+ }
+ return formattedObject;
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Public Methods.
+ //-----------------------------------------------------------------------
+
+ /**
+ * Appends the specified formatter at the end of the chain
+ * @param formatter
+ *
+ * @public
+ * @return {void}
+**/
+xap.data.formatter.FormatterChain.prototype.appendFormatter = function( Formatter formatter ) {
+ /*if(*/
+var formatter = = null ) {
+ throw new IllegalArgumentException( ResourceDictionary.getMessage(
+ NULL_FORMATTER_MSGID, FormatterChain.class ));
+ }
+ if( this._formatters.contains( formatter )) {
+ if( getLog().isDebug() ) {
+ this.getLog().debug( ResourceDictionary.getMessage(
+ FORMATTER_INSTANCE_ALREADY_IN_CHAIN_MSGID,
+ FormatterChain.class,
+ formatter.toString()));
+ }
+ }
+ this._formatters.addElement( formatter );
+ }
+
+ /**
+ * Inserts the specified formatter at the specified index.
+ *
+ * @param formatter
+ * @param index
+ *
+ * @public
+ * @return {void}
+**/
+xap.data.formatter.FormatterChain.prototype.insertFormatterAt = function( Formatter formatter, int index ) {
+ /*if(*/
+var formatter = = null ) {
+ throw new IllegalArgumentException( ResourceDictionary.getMessage(
+ NULL_FORMATTER_MSGID, FormatterChain.class ));
+ }
+ if( this._formatters.contains( formatter )) {
+ if( getLog().isDebug() ) {
+ this.getLog().debug( ResourceDictionary.getMessage(
+ FORMATTER_INSTANCE_ALREADY_IN_CHAIN_MSGID,
+ FormatterChain.class,
+ formatter.toString()));
+ }
+ }
+ this._formatters.insertElementAt( formatter, index );
+ }
+
+ /**
+ * Removes the first occurence of the formatter from this formatter chain.
+ *
+ * @param formatter
+ * @return the removed Formatter instance
+ *
+ * @public
+ * @return {Formatter}
+**/
+xap.data.formatter.FormatterChain.prototype.removeFormatter = function( Formatter formatter ) {
+ /*if(*/
+var formatter = = null ) {
+ throw new IllegalArgumentException( ResourceDictionary.getMessage(
+ NULL_FORMATTER_MSGID, FormatterChain.class ));
+ }
+ /*int*/
+var i = this._formatters.indexOf( formatter );
+ /*if(*/
+var i = = -1 ) {
+ return null;
+ }
+ /*Formatter*/
+var f = (Formatter) this._formatters.elementAt( i );
+ this._formatters.removeElementAt( i );
+ return f;
+ }
+
+ /**
+ * Removes the formatter at the specified index in the chain.
+ *
+ * @param index
+ * @return the removed Formatter instance.
+ *
+ * @public
+ * @return {Formatter}
+**/
+xap.data.formatter.FormatterChain.prototype.removeFormatterAt = function( int index ) {
+ /*Formatter*/
+var f = (Formatter) this._formatters.elementAt( index );
+ this._formatters.removeElementAt( index );
+ return f;
+ }
+
+ /**
+ * Removes all Formatter instances from this chain.
+ *
+ * @public
+ * @return {void}
+**/
+xap.data.formatter.FormatterChain.prototype.removeAll = function() {
+ this._formatters.removeAllElements();
+ }
+
+/**
+ * @private
+ * @return {Log}
+**/
+xap.data.formatter.FormatterChain.prototype.getLog = function(){
+ return LogFactory.getLog( "FormatterChain" );
+ }
+}
Propchange: incubator/xap/trunk/src/xap/data/formatter/FormatterChain.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/xap/trunk/src/xap/data/formatter/FormatterContainerImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/formatter/FormatterContainerImpl.js?view=auto&rev=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/formatter/FormatterContainerImpl.js (added)
+++ incubator/xap/trunk/src/xap/data/formatter/FormatterContainerImpl.js Fri Oct 6 10:36:49 2006
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+Xap.require("xap.session.ClientSession");
+Xap.require("xap.session.Container");
+/**
+ * FormatterContainer implementation.
+ *
+ * @author dgennaco
+**/
+Xap.provide("xap.data.formatter.FormatterContainerImpl");
+xap.data.formatter.FormatterContainerImpl = function (sess) {
+ xap.session.Container.call(sess);
+};
+Xap.setupClassAsSubclassOf("xap.data.formatter.FormatterContainerImpl", "xap.session.Container");
+/* (non-Javadoc)
+ * @see xap.data.formatter.FormatterContainer#getNames()
+ *
+ * @public
+ * @return {String[]}
+**/
+xap.data.formatter.FormatterContainerImpl.prototype.getIds = function () {
+ return this.superclass.getNames.call(this);
+};
+/* (non-Javadoc)
+ * @see xap.data.formatter.FormatterContainer#hasFormatter(xap.data.formatter.Formatter)
+ *
+ * @public
+ * @return {boolean}
+ *
+ * @param formatter{Formatter}
+**/
+xap.data.formatter.FormatterContainerImpl.prototype.hasFormatter = function (formatter) {
+ return this.superclass.containsValue.call(this, formatter);
+};
+/* (non-Javadoc)
+ * @see xap.data.formatter.FormatterContainer#addFormatter(java.lang.String, xap.data.formatter.Formatter)
+ *
+ * @public
+ * @return {void}
+ *
+ * @param name{String}
+ * @param formatter{Formatter }
+**/
+xap.data.formatter.FormatterContainerImpl.prototype.addFormatter = function (name, formatter) {
+ this.superclass.put.call(this, name, formatter);
+};
+/* (non-Javadoc)
+ * @see xap.data.formatter.FormatterContainer#getName(xap.data.formatter.Formatter)
+ *
+ * @public
+ * @return {String}
+ *
+ * @param formatter{Formatter}
+**/
+xap.data.formatter.FormatterContainerImpl.prototype.getId = function (formatter) {
+ return this.superclass.getName.call(this, formatter);
+};
+/* (non-Javadoc)
+ * @see xap.data.formatter.FormatterContainer#getFormatter(java.lang.String)
+ *
+ * @public
+ * @return {Formatter}
+ *
+ * @param name{String}
+**/
+xap.data.formatter.FormatterContainerImpl.prototype.getFormatter = function (name) {
+ return this.superclass.get.call(this, name);
+};
+/* (non-Javadoc)
+ * @see xap.data.formatter.FormatterContainer#removeFormatter(xap.data.formatter.Formatter)
+ *
+ * @public
+ * @return {boolean}
+ *
+ * @param formatter{Formatter}
+**/
+xap.data.formatter.FormatterContainerImpl.prototype.removeFormatter = function (formatter) {
+ return this.superclass.removeValue.call(this, formatter);
+};
+/* (non-Javadoc)
+ * @see xap.data.formatter.FormatterContainer#removeFormatter(java.lang.String)
+ *
+ * @public
+ * @return {Formatter}
+ *
+ * @param name{String}
+**/
+xap.data.formatter.FormatterContainerImpl.prototype.removeFormatter = function (name) {
+ return this.superclass.remove.call(this, name);
+};
+/* (non-Javadoc)
+ * @see xap.data.formatter.FormatterContainer#getFormatters()
+ *
+ * @public
+ * @return {Formatter[]}
+**/
+xap.data.formatter.FormatterContainerImpl.prototype.getFormatters = function () {
+ /*Object []*/
+ var objects = getObjects();
+ /*Formatter []*/
+ var retArray = new Formatter[objects.length];
+ for (var i = 0; i < retArray.length; i++) {
+ retArray[i] = objects[i];
+ }
+ return retArray;
+};
+
Added: incubator/xap/trunk/src/xap/data/formatter/JsFormatterImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/formatter/JsFormatterImpl.js?view=auto&rev=453699
==============================================================================
--- incubator/xap/trunk/src/xap/data/formatter/JsFormatterImpl.js (added)
+++ incubator/xap/trunk/src/xap/data/formatter/JsFormatterImpl.js Fri Oct 6 10:36:49 2006
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ **/
+/**
+ * Ease-of-use base class for Formatter implementations that use
+ * instances of the java.text.Format.
+ *
+ * @author ikaplansky
+ */
+Xap.provide("xap.data.formatter.JsFormatterImpl");
+Xap.require("xap.util.Exception");
+xap.data.formatter.JsFormatterImpl = function () {
+};
+Xap.setupClassAsSubclassOf("xap.data.formatter.JsFormatterImpl", "Object");
+//-----------------------------------------------------------------------
+// Instance Variables.
+//-----------------------------------------------------------------------
+/**
+ * @private Format
+**/
+xap.data.formatter.JsFormatterImpl.prototype._format = null;
+/**
+ * private ClientSession
+ **/
+xap.data.formatter.JsFormatterImpl.prototype._session = null;
+/**
+ * @private Element
+**/
+xap.data.formatter.JsFormatterImpl.prototype._formatterElement = null;
+//-----------------------------------------------------------------------
+// Formatter Interface.
+//-----------------------------------------------------------------------
+/**
+ * @see Formatter#initialize(String, ClientSession, Element)
+ *
+ * @public
+ * @return {void}
+ *
+ * @param id{String}
+ * @param session{ClientSession}
+ * @param formatterElement{Element }
+ * @throws InitializationException
+**/
+xap.data.formatter.JsFormatterImpl.prototype.initialize = function (id, session, formatterElement) {
+ this._session = session;
+ this._formatterElement = formatterElement;
+};
+/**
+ * @see Formatter#format(Object)
+ *
+ * @public
+ * @param object{Object}
+ * @return {Object}
+ * @throws FormatException
+**/
+xap.data.formatter.JsFormatterImpl.prototype.format = function (object) {
+ try {
+ if (object != null) {
+ return this.formatObject(object);
+ }
+ throw new FormatException(FormatException.NULL_FORMAT_ARGUMENT_MSGID);
+ }
+ catch (e) { // IllegalArgumentException
+ throw new FormatException(FormatException.ILLEGAL_FORMAT_ARG_MSGID, object.toString(), e);
+ }
+};
+//-----------------------------------------------------------------------
+// Public Methods.
+//-----------------------------------------------------------------------
+/**
+ * Sets the Format instance for this Formatter
+ * @param format - Format instance
+ *
+ * @public
+ * @param format{Format}
+ * @return {void}
+**/
+xap.data.formatter.JsFormatterImpl.prototype.setFormat = function (format) {
+ this._format = format;
+};
+/**
+ * @return this formatter's Format instance
+ *
+ * @public
+ * @return {Format}
+**/
+xap.data.formatter.JsFormatterImpl.prototype.getFormat = function () {
+ return this._format;
+};
+//-----------------------------------------------------------------------
+// Protected Methods.
+//-----------------------------------------------------------------------
+/**
+ * @protected
+ * @return {Log}
+**/
+xap.data.formatter.JsFormatterImpl.prototype.getLog = function () {
+ return LogFactory.getLog("Formatter");
+};
+/**
+ * @protected
+ * @return {ClientSession}
+**/
+xap.data.formatter.JsFormatterImpl.prototype.getSession = function () {
+ return this._session;
+};
+/**
+ * @protected
+ * @return {Element}
+**/
+xap.data.formatter.JsFormatterImpl.prototype.getFormatterElement = function () {
+ return this._formatterElement;
+};
+/**
+ * @protected
+ * @param session{ClientSession}
+ * @return {void}
+**/
+xap.data.formatter.JsFormatterImpl.prototype.setSession = function (session) {
+ this._session = session;
+};
+//-----------------------------------------------------------------------
+// Protected Abstract Methods.
+//-----------------------------------------------------------------------
+/**
+ * Format the specified object according to this Formatter's configuration
+ *
+ * @param object to format
+ * @return formatted object
+ * @throws FormatException
+ *
+ * @protected
+ * @param object{Object}
+ * @return {Object}
+ * @throws FormatException;
+**/
+xap.data.formatter.JsFormatterImpl.prototype.formatObject = function (object) {
+};
+