Author: Alex.Kolonitsky
Date: 2009-12-04 15:49:13 -0500 (Fri, 04 Dec 2009)
New Revision: 16072
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/application/InitializationListener.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/EnclosingFormRequiredException.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/FileUploadConstants.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/SavedState.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/UIRangedNumberInput.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/UISequence.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/nsutils/NSUtils.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/nsutils/package-info.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/package-info.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/AbstractMessageUtil.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ComponentMessageUtil.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ComponentUtil.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/FormUtil.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/MessageUtil.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ViewUtil.java
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/package-info.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentCallback.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/ContextProvider.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/ExecuteComponentCallback.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextAjaxOutputTracker.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/SingletonsContext.java
root/framework/trunk/impl/src/main/java/org/richfaces/event/SwitchablePanelSwitchEvent.java
root/framework/trunk/impl/src/main/java/org/richfaces/event/package-info.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/CDL.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/Cookie.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/CookieList.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/HTTP.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/HTTPTokener.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSContentHandler.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONAccessor.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONArray.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONCollection.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONException.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONMap.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONObject.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONString.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONStringer.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONTokener.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONWriter.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/XML.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/XMLTokener.java
root/framework/trunk/impl/src/main/java/org/richfaces/json/package-info.java
Log:
RFPL-195 - Code style policy
Reformatting
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/application/InitializationListener.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/application/InitializationListener.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/application/InitializationListener.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -21,13 +21,13 @@
*/
package org.richfaces.application;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.text.MessageFormat;
+import org.ajax4jsf.cache.CacheManager;
+import org.ajax4jsf.renderkit.AJAXDataSerializer;
+import org.ajax4jsf.resource.util.URLToStreamHelper;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.skin.SkinFactory;
+import org.richfaces.skin.SkinFactoryImpl;
+import org.slf4j.Logger;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
@@ -36,90 +36,95 @@
import javax.faces.event.PreDestroyApplicationEvent;
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.text.MessageFormat;
-import org.ajax4jsf.cache.CacheManager;
-import org.ajax4jsf.renderkit.AJAXDataSerializer;
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.richfaces.log.RichfacesLogger;
-import org.richfaces.skin.SkinFactory;
-import org.richfaces.skin.SkinFactoryImpl;
-import org.slf4j.Logger;
-
/**
* @author Nick Belaevski
* @since 4.0
*/
public class InitializationListener implements SystemEventListener {
- private static final String META_INF_SERVICES = "META-INF/services/";
-
- private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
-
- /* (non-Javadoc)
- * @see javax.faces.event.SystemEventListener#isListenerForSource(java.lang.Object)
- */
- public boolean isListenerForSource(Object source) {
- return true;
- }
+ private static final String META_INF_SERVICES = "META-INF/services/";
- private static <T> T instantiate(Class<T> interfaceClass,
- Class<? extends T> implementationClass,
- Class<? extends T> defaultImplementationClass) {
+ private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
- Constructor<? extends T> constructor = null;
- Object[] constructorArguments = null;
+ /* (non-Javadoc)
+ * @see javax.faces.event.SystemEventListener#isListenerForSource(java.lang.Object)
+ */
+ public boolean isListenerForSource(Object source) {
+ return true;
+ }
- if (implementationClass != null) {
- if (defaultImplementationClass != null &&
!defaultImplementationClass.equals(implementationClass)) {
- try {
- constructor = implementationClass.getConstructor(interfaceClass);
- T defaultImplementation = instantiate(interfaceClass, defaultImplementationClass,
null);
- constructorArguments = new Object[]{defaultImplementation};
- } catch (NoSuchMethodException e) {
- /* ignore */
- }
- }
+ private static <T> T instantiate(Class<T> interfaceClass,
+ Class<? extends T> implementationClass,
+ Class<? extends T> defaultImplementationClass)
{
- if (constructor == null) {
- try {
- constructor = implementationClass.getConstructor();
- } catch (NoSuchMethodException e) {
- throw new FacesException(MessageFormat.format("Class {0} has no public no-arg
constructor", implementationClass.getName()), e);
- }
- }
+ Constructor<? extends T> constructor = null;
+ Object[] constructorArguments = null;
- } else {
- try {
- constructor = defaultImplementationClass.getConstructor();
- } catch (NoSuchMethodException e) {
- throw new FacesException(MessageFormat.format("Class {0} has no public no-arg
constructor",
- defaultImplementationClass.getName()), e);
- }
- }
+ if (implementationClass != null) {
+ if (defaultImplementationClass != null &&
!defaultImplementationClass.equals(implementationClass)) {
+ try {
+ constructor = implementationClass.getConstructor(interfaceClass);
+ T defaultImplementation = instantiate(interfaceClass,
defaultImplementationClass, null);
+ constructorArguments = new Object[]{defaultImplementation};
+ } catch (NoSuchMethodException e) {
+ /* ignore */
+ }
+ }
- try {
- return constructor.newInstance(constructorArguments);
- } catch (IllegalArgumentException e) {
- throw new FacesException(MessageFormat.format("Cannot instantiate {0} class,
error was: {1}", constructor.getDeclaringClass(), e.getMessage()), e);
- } catch (InstantiationException e) {
- throw new FacesException(MessageFormat.format("Cannot instantiate {0} class,
error was: {1}", constructor.getDeclaringClass(), e.getMessage()), e);
- } catch (IllegalAccessException e) {
- throw new FacesException(MessageFormat.format("Cannot instantiate {0} class,
error was: {1}", constructor.getDeclaringClass(), e.getMessage()), e);
- } catch (InvocationTargetException e) {
- Throwable cause = e.getCause();
- if (cause == null) {
- cause = e;
- }
- throw new FacesException(MessageFormat.format("Cannot instantiate {0} class,
error was: {1}", constructor.getDeclaringClass(), cause.getMessage()), cause);
- }
- }
-
- private static final <T> T createServiceInstance(Class<T> interfaceClass,
Class<? extends T> defaultImplementationClass) {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- InputStream input =
URLToStreamHelper.urlToStreamSafe(loader.getResource(META_INF_SERVICES +
interfaceClass.getName()));
+ if (constructor == null) {
+ try {
+ constructor = implementationClass.getConstructor();
+ } catch (NoSuchMethodException e) {
+ throw new FacesException(MessageFormat.format("Class {0} has no
public no-arg constructor",
+ implementationClass.getName()), e);
+ }
+ }
- Class<? extends T> implementationClass = null;
+ } else {
+ try {
+ constructor = defaultImplementationClass.getConstructor();
+ } catch (NoSuchMethodException e) {
+ throw new FacesException(MessageFormat.format("Class {0} has no
public no-arg constructor",
+ defaultImplementationClass.getName()), e);
+ }
+ }
+ try {
+ return constructor.newInstance(constructorArguments);
+ } catch (IllegalArgumentException e) {
+ throw new FacesException(MessageFormat.format("Cannot instantiate {0}
class, error was: {1}",
+ constructor.getDeclaringClass(), e.getMessage()), e);
+ } catch (InstantiationException e) {
+ throw new FacesException(MessageFormat.format("Cannot instantiate {0}
class, error was: {1}",
+ constructor.getDeclaringClass(), e.getMessage()), e);
+ } catch (IllegalAccessException e) {
+ throw new FacesException(MessageFormat.format("Cannot instantiate {0}
class, error was: {1}",
+ constructor.getDeclaringClass(), e.getMessage()), e);
+ } catch (InvocationTargetException e) {
+ Throwable cause = e.getCause();
+ if (cause == null) {
+ cause = e;
+ }
+ throw new FacesException(MessageFormat.format("Cannot instantiate {0}
class, error was: {1}",
+ constructor.getDeclaringClass(), cause.getMessage()), cause);
+ }
+ }
+
+ private static <T> T createServiceInstance(Class<T> interfaceClass,
Class<? extends T> defaultImplementationClass) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ InputStream input = URLToStreamHelper.urlToStreamSafe(
+ loader.getResource(META_INF_SERVICES + interfaceClass.getName()));
+
+ Class<? extends T> implementationClass = null;
+
// have services file.
if (input != null) {
try {
@@ -128,10 +133,10 @@
implementationClass = Class.forName(factoryClassName, false,
loader).asSubclass(interfaceClass);
} catch (Exception e) {
- LOG.warn(MessageFormat.format("Error loading class for {0} service: {1}
",
- interfaceClass.getName(), e.getMessage()), e);
- } finally {
- try {
+ LOG.warn(MessageFormat.format("Error loading class for {0} service:
{1} ",
+ interfaceClass.getName(), e.getMessage()), e);
+ } finally {
+ try {
input.close();
} catch (IOException e) {
// can be ignored
@@ -143,34 +148,33 @@
}
protected void onStart() {
- FacesContext facesContext = FacesContext.getCurrentInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
- SkinFactory skinFactory = createServiceInstance(SkinFactory.class,
SkinFactoryImpl.class);
- ServiceTracker.setService(facesContext, SkinFactory.class, skinFactory);
-
- AJAXDataSerializer dataSerializer = createServiceInstance(AJAXDataSerializer.class,
AJAXDataSerializer.class);
- ServiceTracker.setService(facesContext, AJAXDataSerializer.class, dataSerializer);
+ SkinFactory skinFactory = createServiceInstance(SkinFactory.class,
SkinFactoryImpl.class);
+ ServiceTracker.setService(facesContext, SkinFactory.class, skinFactory);
+
+ AJAXDataSerializer dataSerializer =
createServiceInstance(AJAXDataSerializer.class, AJAXDataSerializer.class);
+ ServiceTracker.setService(facesContext, AJAXDataSerializer.class,
dataSerializer);
}
-
+
protected void onStop() {
- FacesContext facesContext = FacesContext.getCurrentInstance();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
- ServiceTracker.release(facesContext);
+ ServiceTracker.release(facesContext);
CacheManager.getInstance().destroy();
}
-
-
- /* (non-Javadoc)
- * @see
javax.faces.event.SystemEventListener#processEvent(javax.faces.event.SystemEvent)
- */
- public void processEvent(SystemEvent event) throws AbortProcessingException {
- if (event instanceof PostConstructApplicationEvent) {
- onStart();
- } else if (event instanceof PreDestroyApplicationEvent) {
- onStop();
- } else {
- throw new IllegalArgumentException(MessageFormat.format("Event {0} is not
supported!", event));
- }
- }
+ /* (non-Javadoc)
+ * @see
javax.faces.event.SystemEventListener#processEvent(javax.faces.event.SystemEvent)
+ */
+ public void processEvent(SystemEvent event) throws AbortProcessingException {
+ if (event instanceof PostConstructApplicationEvent) {
+ onStart();
+ } else if (event instanceof PreDestroyApplicationEvent) {
+ onStop();
+ } else {
+ throw new IllegalArgumentException(MessageFormat.format("Event {0} is
not supported!", event));
+ }
+ }
+
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/EnclosingFormRequiredException.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/EnclosingFormRequiredException.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/EnclosingFormRequiredException.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,16 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component;
import javax.faces.FacesException;
/**
* @author Filip Antonov - mailto:fantonov@exadel.com
- * created 08.02.2007
- *
+ * created 08.02.2007
*/
public class EnclosingFormRequiredException extends FacesException {
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/FileUploadConstants.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/FileUploadConstants.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/FileUploadConstants.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component;
import org.ajax4jsf.request.MultipartRequest;
@@ -34,19 +32,29 @@
public static final String FILE_UPLOAD_ACTION_PROGRESS = "progress";
public static final String FILE_UPLOAD_ACTION_STOP =
"richfaces_file_upload_action_stop";
- /** Request parameter name indicated that file was uploaded by RF component */
+ /**
+ * Request parameter name indicated that file was uploaded by RF component
+ */
public static final String FILE_UPLOAD_INDICATOR =
"_richfaces_upload_file_indicator";
- /** Session bean name where progress bar's percent map will be stored */
+ /**
+ * Session bean name where progress bar's percent map will be stored
+ */
public static final String PERCENT_BEAN_NAME =
"_richfaces_upload_percents";
- /** Session bean name where stop keys will be stored */
+ /**
+ * Session bean name where stop keys will be stored
+ */
public static final String REQUEST_KEYS_BEAN_NAME =
"_richfaces_request_keys";
- /** Session bean name where request size will be stored */
+ /**
+ * Session bean name where request size will be stored
+ */
public static final String REQUEST_SIZE_BEAN_NAME =
"_richfaces_request_size";
- /** Session bean name to store max files count allowed to upload */
+ /**
+ * Session bean name to store max files count allowed to upload
+ */
public static final String UPLOADED_COUNTER =
"_richfaces_uploaded_file_counter";
/**
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -20,8 +20,6 @@
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-
-
package org.richfaces.component;
import javax.faces.component.UIComponent;
@@ -31,7 +29,6 @@
/**
* @author Nick Belaevski
- *
*/
class RowKeyContextEventWrapper extends FacesEvent {
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/component/SavedState.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/SavedState.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/SavedState.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -20,16 +20,13 @@
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-
-
package org.richfaces.component;
import org.ajax4jsf.component.IterationStateHolder;
-import java.io.Serializable;
-
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIForm;
+import java.io.Serializable;
//from RI
@@ -38,7 +35,6 @@
* fields.
*
* @author shura
- *
*/
final class SavedState implements Serializable {
public static final SavedState EMPTY = new SavedState();
@@ -118,7 +114,7 @@
return "iterationState: " + iterationState;
} else {
return "submittedValue: " + submittedValue + " value: " +
value + " localValueSet: " + localValueSet
- + " submitted: " + submitted;
+ + " submitted: " + submitted;
}
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -20,8 +20,6 @@
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-
-
package org.richfaces.component;
import org.ajax4jsf.component.AjaxDataEncoder;
@@ -32,25 +30,10 @@
import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.Range;
import org.ajax4jsf.model.SerializableDataModel;
-
import org.richfaces.log.RichfacesLogger;
-
import org.slf4j.Logger;
-import java.io.IOException;
-import java.io.Serializable;
-
-import java.text.MessageFormat;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
import javax.el.ValueExpression;
-
import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
import javax.faces.component.ContextCallback;
@@ -75,6 +58,15 @@
import javax.faces.event.BehaviorEvent;
import javax.faces.event.FacesEvent;
import javax.faces.render.Renderer;
+import java.io.IOException;
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
/**
* Base class for iterable components, like dataTable, Tomahawk dataList,
@@ -82,12 +74,11 @@
* responces for one or more selected iterations.
*
* @author shura
- *
*/
//TODO check AjaxDataEncoder
public abstract class UIDataAdaptor extends UIComponentBase
- implements AjaxDataEncoder, NamingContainer, UniqueIdVendor, IterationStateHolder
{
+ implements AjaxDataEncoder, NamingContainer, UniqueIdVendor, IterationStateHolder {
/**
* <p>The standard component family for this component.</p>
@@ -101,7 +92,6 @@
private static final Logger LOG = RichfacesLogger.COMPONENTS.getLogger();
-
/**
* Visitor for process decode on children components.
*/
@@ -221,9 +211,8 @@
* tree.
*
* @param faces -
- * current FacesContext
- * @param key
- * new key value.
+ * current FacesContext
+ * @param key new key value.
*/
public void setRowKey(FacesContext facesContext, Object rowKey) {
this.saveChildState(facesContext);
@@ -328,6 +317,7 @@
/**
* Restore values of {@link EditableValueHolder} fields after change current
* row.
+ *
* @param facesContext
* @param next
* @param childState
@@ -458,7 +448,7 @@
* from {@link #broadcast(FacesEvent)}
*
* @param event -
- * processed event.
+ * processed event.
* @return true if event processed, false if component must continue
* processing.
*/
@@ -532,11 +522,10 @@
* Setup EL variable for different iteration. Value of row data and
* component state will be put into request scope attributes with names
* given by "var" and "varState" bean properties.
- *
+ * <p/>
* Changed: does not check for row availability now
*
- * @param faces
- * current faces context
+ * @param faces current faces context
* @param localModel
* @param rowSelected
*/
@@ -578,7 +567,7 @@
componentState = createComponentState();
if ((componentStateExpression != null)
- &&
!componentStateExpression.isReadOnly(getFacesContext().getELContext())) {
+ &&
!componentStateExpression.isReadOnly(getFacesContext().getELContext())) {
componentStateExpression.setValue(getFacesContext().getELContext(),
componentState);
}
}
@@ -675,8 +664,7 @@
/**
* Save current state of data variable.
*
- * @param faces
- * current faces context
+ * @param faces current faces context
*/
// TODO move into walk() method body
@@ -695,8 +683,7 @@
/**
* Restore value of data variable after processing phase.
*
- * @param faces
- * current faces context
+ * @param faces current faces context
*/
public void restoreOrigValue(FacesContext faces) {
String var = getVar();
@@ -783,10 +770,10 @@
* @param visitor
*/
public void walk(FacesContext faces, DataVisitor visitor, Object argument) {
- Object key = getRowKey();
- captureOrigValue(faces);
-
- Range range = null;
+ Object key = getRowKey();
+ captureOrigValue(faces);
+
+ Range range = null;
DataComponentState componentState = getComponentState();
if (componentState != null) {
@@ -794,11 +781,11 @@
}
getExtendedDataModel().walk(faces, visitor, range, argument);
-
- setRowKey(key);
- restoreOrigValue(faces);
+
+ setRowKey(key);
+ restoreOrigValue(faces);
}
-
+
public void processDecodes(FacesContext faces) {
if (!this.isRendered()) {
return;
@@ -849,8 +836,8 @@
StateHelper stateHelper = getStateHelper();
- return new Object[] {stateHelper.get(PropertyKeys.childState),
this.componentState, this.ajaxRowKey,
- this.extendedDataModel, };
+ return new Object[]{stateHelper.get(PropertyKeys.childState),
this.componentState, this.ajaxRowKey,
+ this.extendedDataModel,};
}
/*
@@ -929,7 +916,7 @@
}
}
- return new Object[] {super.saveState(context), savedComponentState,
componentStateIsStateHolder};
+ return new Object[]{super.saveState(context), savedComponentState,
componentStateIsStateHolder};
}
/*
@@ -966,7 +953,7 @@
// if clientId.startsWith(baseId + separatorChar)
if (clientId.startsWith(baseId) && (clientId.length() >
baseId.length())
- && (clientId.charAt(baseId.length()) == separatorChar)) {
+ && (clientId.charAt(baseId.length()) == separatorChar)) {
return true;
}
@@ -976,7 +963,7 @@
@Override
public boolean invokeOnComponent(FacesContext context, String clientId,
ContextCallback callback)
throws FacesException {
-
+
if ((null == context) || (null == clientId) || (null == callback)) {
throw new NullPointerException();
}
@@ -1118,7 +1105,7 @@
private boolean visitDataChildren(final VisitContext visitContext, final
VisitCallback callback) {
FacesContext facesContext = visitContext.getFacesContext();
- final boolean[] singleBoolean = new boolean[] {false};
+ final boolean[] singleBoolean = new boolean[]{false};
this.walk(facesContext, new DataVisitor() {
public DataVisitResult process(FacesContext context, Object rowKey, Object
argument) {
@@ -1222,7 +1209,6 @@
* model
*
* @author shura
- *
*/
protected abstract class ComponentVisitor implements DataVisitor {
public DataVisitResult process(FacesContext context, Object rowKey, Object
argument) {
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/UIRangedNumberInput.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/UIRangedNumberInput.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/UIRangedNumberInput.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component;
import org.richfaces.component.util.MessageUtil;
@@ -31,8 +29,7 @@
/**
* @author Nick - mailto:nbelaevski@exadel.com
- * created 20.02.2007
- *
+ * created 20.02.2007
*/
public abstract class UIRangedNumberInput extends UIInput {
public abstract String getMaxValue();
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/component/UISequence.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/UISequence.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/UISequence.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -20,8 +20,6 @@
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-
-
package org.richfaces.component;
import org.ajax4jsf.model.DataComponentState;
@@ -29,11 +27,6 @@
import org.ajax4jsf.model.RepeatState;
import org.ajax4jsf.model.SequenceDataModel;
-import java.sql.ResultSet;
-
-import java.util.Collections;
-import java.util.List;
-
import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
@@ -43,15 +36,18 @@
import javax.faces.model.ResultDataModel;
import javax.faces.model.ResultSetDataModel;
import javax.faces.model.ScalarDataModel;
-
import javax.servlet.jsp.jstl.sql.Result;
+import java.sql.ResultSet;
+import java.util.Collections;
+import java.util.List;
/**
* @author Nick Belaevski
- *
*/
public class UISequence extends UIDataAdaptor {
- protected enum PropertyKeys {first, rows, value}
+ protected enum PropertyKeys {
+ first, rows, value
+ }
@SuppressWarnings("unchecked")
protected DataModel<?> createFacesModel(Object value) {
@@ -111,6 +107,7 @@
public int getFirst() {
return UISequence.this.getFirst();
}
+
@Override
public int getRows() {
return UISequence.this.getRows();
@@ -124,6 +121,7 @@
*/
// TODO make this a property of model
+
@Override
public Converter getRowKeyConverter() {
return getFacesContext().getApplication().createConverter(Integer.class);
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,18 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
-
import org.richfaces.event.SwitchablePanelSwitchEvent;
-import java.util.Iterator;
-
import javax.el.ValueExpression;
-
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
@@ -39,11 +33,11 @@
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.ValueChangeEvent;
+import java.util.Iterator;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 23.01.2007
- *
+ * created 23.01.2007
*/
public abstract class UISwitchablePanel extends UIInput {
@@ -137,8 +131,8 @@
if (AjaxRendererUtils.isAjaxRequest(facesContext)
- /* && this.getSwitchType().equals(AJAX_METHOD) */
- ) { // RF-7292
+ /* && this.getSwitchType().equals(AJAX_METHOD) */
+ ) { // RF-7292
AjaxRendererUtils.addRegionByName(facesContext, this, this.getId());
}
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/nsutils/NSUtils.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/nsutils/NSUtils.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/nsutils/NSUtils.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,26 +19,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component.nsutils;
-import java.io.IOException;
-
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import java.io.IOException;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 21.12.2006
- *
+ * created 21.12.2006
*/
public final class NSUtils {
public static final String XMLNS_PREFIX = "rich";
public static final String XMLNS_URI =
"http://richfaces.ajax4jsf.org/rich";
public static final String XMLNS_VALUE = "xmlns:" + XMLNS_PREFIX;
- private NSUtils() {}
+ private NSUtils() {
+ }
public static void writeNameSpace(FacesContext context, UIComponent component) throws
IOException {
context.getResponseWriter().writeAttribute(NSUtils.XMLNS_VALUE,
NSUtils.XMLNS_URI, null);
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/nsutils/package-info.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/nsutils/package-info.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/nsutils/package-info.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -1,4 +1,3 @@
-
/**
* Custom XML namespace utility classes
*/
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/package-info.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/package-info.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/package-info.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -1,4 +1,3 @@
-
/**
* Base RichFaces component classes
*/
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/AbstractMessageUtil.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/AbstractMessageUtil.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/AbstractMessageUtil.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,28 +19,26 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component.util;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
import java.text.MessageFormat;
-
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-
/**
* Created 19.06.2008
+ *
* @author Nick Belaevski
* @since 3.2.2
*/
public final class AbstractMessageUtil {
- private AbstractMessageUtil() {}
+ private AbstractMessageUtil() {
+ }
private static ResourceBundle getResourceBundle(String baseName, Locale locale,
ClassLoader loader) {
if (loader != null) {
@@ -51,7 +49,7 @@
}
private static FacesMessage getMessage(FacesContext context, String messageId,
Object[] parameters, Locale locale,
- String baseBundleName) {
+ String baseBundleName) {
String summary = null;
String detail = null;
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ComponentMessageUtil.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ComponentMessageUtil.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ComponentMessageUtil.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component.util;
import javax.faces.application.FacesMessage;
@@ -33,7 +31,8 @@
public final class ComponentMessageUtil {
public static final String MESSAGE_BUNDLE_NAME =
"org.richfaces.component.messages";
- private ComponentMessageUtil() {}
+ private ComponentMessageUtil() {
+ }
public static FacesMessage getMessage(FacesContext context, String messageId,
Object[] parameters) {
return AbstractMessageUtil.getMessage(context, messageId, parameters,
MESSAGE_BUNDLE_NAME);
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ComponentUtil.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ComponentUtil.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ComponentUtil.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component.util;
import java.util.Collection;
@@ -30,10 +28,10 @@
* @author Nick Belaevski
* mailto:nbelaevski@exadel.com
* created 20.07.2007
- *
*/
public final class ComponentUtil {
- private ComponentUtil() {}
+ private ComponentUtil() {
+ }
public static String[] asArray(Object object) {
if (object == null) {
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/FormUtil.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/FormUtil.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/FormUtil.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,12 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component.util;
import org.ajax4jsf.renderkit.RendererUtils;
-
import org.richfaces.component.EnclosingFormRequiredException;
import javax.faces.component.UIComponent;
@@ -33,15 +30,15 @@
/**
* @author Filip Antonov - mailto:fantonov@exadel.com
- * created 08.02.2007
- *
+ * created 08.02.2007
*/
public final class FormUtil {
- private FormUtil() {}
+ private FormUtil() {
+ }
public static void throwEnclFormReqExceptionIfNeed(FacesContext context, UIComponent
component)
throws EnclosingFormRequiredException {
-
+
UIForm form = RendererUtils.getInstance().getNestingForm(context, component);
// TODO nick -> nick - switchType checking can be harmful here
@@ -50,7 +47,7 @@
if ((form == null) && !isSwitchTypeClient) {
throw new EnclosingFormRequiredException(component.getClass().toString() +
" (id=\"" + component.getId()
- + "\") did not find parent form.");
+ + "\") did not find parent form.");
}
}
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,23 +19,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component.util;
import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.util.HtmlDimensions;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com created 09.02.2007
- *
*/
public final class HtmlUtil {
public static final Pattern ID_SELECTOR_PATTERN =
@@ -44,7 +40,8 @@
private static final String ORG_AJAX4JSF = "org.ajax4jsf.";
private static final String ORG_RICHFACES = "org.richfaces.";
- private HtmlUtil() {}
+ private HtmlUtil() {
+ }
public static String qualifySize(String sizeDeclaration) {
String trimmedValue = sizeDeclaration.trim();
@@ -115,7 +112,7 @@
}
if ((rendererType != null)
- && (rendererType.startsWith(ORG_AJAX4JSF) ||
rendererType.startsWith(ORG_RICHFACES))) {
+ && (rendererType.startsWith(ORG_AJAX4JSF) ||
rendererType.startsWith(ORG_RICHFACES))) {
return true;
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/MessageUtil.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/MessageUtil.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/MessageUtil.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component.util;
import javax.faces.application.Application;
@@ -31,8 +29,7 @@
/**
* @author Nick - mailto:nbelaevski@exadel.com
- * created 06.02.2007
- *
+ * created 06.02.2007
*/
public final class MessageUtil {
private static final boolean IS_12;
@@ -50,7 +47,8 @@
IS_12 = is12;
}
- private MessageUtil() {}
+ private MessageUtil() {
+ }
public static Object getLabel(FacesContext context, UIComponent component) {
Object o = null;
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ViewUtil.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ViewUtil.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ViewUtil.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,19 +19,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.component.util;
import javax.faces.context.FacesContext;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 19.02.2007
- *
+ * created 19.02.2007
*/
public final class ViewUtil {
- private ViewUtil() {}
+ private ViewUtil() {
+ }
public static String getResourceURL(String url) {
if (null == url) {
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/package-info.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/package-info.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/package-info.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -1,4 +1,3 @@
-
/**
* Common utility classes
*/
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentCallback.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentCallback.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/context/ComponentCallback.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,13 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.context;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
+import org.ajax4jsf.component.AjaxClientBehavior;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
import javax.faces.component.UIComponent;
import javax.faces.component.behavior.ClientBehavior;
@@ -34,22 +32,21 @@
import javax.faces.component.visit.VisitContext;
import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
-import org.ajax4jsf.component.AjaxClientBehavior;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
-
/**
* User: akolonitsky
* Date: Oct 13, 2009
*/
abstract class ComponentCallback implements VisitCallback {
-
- private Collection<String> componentIds = new LinkedHashSet<String>();
-
- private final String behaviorEvent;
- private final String defaultIdAttribute;
-
+
+ private Collection<String> componentIds = new LinkedHashSet<String>();
+
+ private final String behaviorEvent;
+ private final String defaultIdAttribute;
+
ComponentCallback(String behaviorEvent, String defaultIdAttribute) {
super();
@@ -58,7 +55,7 @@
}
protected String getDefaultComponentId() {
- return null;
+ return null;
}
private AjaxClientBehavior findBehavior(UIComponent target) {
@@ -100,14 +97,14 @@
//TODO - unit tests check for "@none" element
Collection<String> attributeIds =
AjaxRendererUtils.asSet(attributeObject);
if (attributeIds == null) {
- attributeIds = new LinkedHashSet<String>();
+ attributeIds = new LinkedHashSet<String>();
}
-
+
if (attributeIds.isEmpty() && defaultIdAttribute != null) {
// asSet() returns copy of original set and we're free to modify it
- attributeIds.add(defaultIdAttribute);
+ attributeIds.add(defaultIdAttribute);
}
-
+
componentIds.addAll(RendererUtils.getInstance().findComponentsFor(context,
target, attributeIds));
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/ContextProvider.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/context/ContextProvider.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/context/ContextProvider.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,14 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.context;
+import javax.faces.context.FacesContext;
import java.util.Map;
-import javax.faces.context.FacesContext;
-
/**
* @author akolonitsky
* @since Oct 13, 2009
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/ExecuteComponentCallback.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/context/ExecuteComponentCallback.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/context/ExecuteComponentCallback.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -21,18 +21,18 @@
package org.richfaces.context;
-import javax.faces.component.UIComponent;
-
import org.ajax4jsf.component.AjaxClientBehavior;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import javax.faces.component.UIComponent;
+
/**
* @author akolonitsky
* @since Oct 13, 2009
*/
class ExecuteComponentCallback extends ComponentCallback {
-
- ExecuteComponentCallback(String behaviorEvent) {
+
+ ExecuteComponentCallback(String behaviorEvent) {
super(behaviorEvent, AjaxRendererUtils.ALL);
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextAjaxOutputTracker.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextAjaxOutputTracker.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextAjaxOutputTracker.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,27 +19,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.context;
import org.ajax4jsf.component.AjaxOutput;
-import java.util.ArrayList;
-import java.util.Collection;
-
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
+import java.util.ArrayList;
+import java.util.Collection;
/**
* @author Nick Belaevski
- *
*/
public class PartialViewContextAjaxOutputTracker implements SystemEventListener {
private static final String AJAX_OUTPUT_COMPONENTS_SET_ATTRIBUTE =
PartialViewContextAjaxOutputTracker.class
- +
":AjaxOutputComponentsSet";
+ + ":AjaxOutputComponentsSet";
static Collection<AjaxOutput> getAjaxOutputComponentsSet(FacesContext context)
{
AttributesContext attributes = SingletonsContext.FACES_CONTEXT.get(context);
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextFactoryImpl.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,18 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.context;
-import java.util.Map;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialViewContext;
import javax.faces.context.PartialViewContextFactory;
+import java.util.Map;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-
/**
* @author Nick Belaevski
* @since 4.0
@@ -47,13 +44,13 @@
@Override
public PartialViewContext getPartialViewContext(final FacesContext context) {
Map<String, String> requestParameterMap =
context.getExternalContext().getRequestParameterMap();
- String activatorComponentId =
requestParameterMap.get(AjaxRendererUtils.AJAX_COMPONENT_ID_PARAMETER);
+ String activatorComponentId =
requestParameterMap.get(AjaxRendererUtils.AJAX_COMPONENT_ID_PARAMETER);
if (activatorComponentId != null) {
- String behaviorEvent =
requestParameterMap.get(AjaxRendererUtils.BEHAVIOR_EVENT_PARAMETER);
-
- return new PartialViewContextImpl(context, activatorComponentId,
behaviorEvent);
+ String behaviorEvent =
requestParameterMap.get(AjaxRendererUtils.BEHAVIOR_EVENT_PARAMETER);
+
+ return new PartialViewContextImpl(context, activatorComponentId,
behaviorEvent);
} else {
- return parentFactory.getPartialViewContext(context);
+ return parentFactory.getPartialViewContext(context);
}
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -21,18 +21,13 @@
*/
package org.richfaces.context;
+import org.ajax4jsf.component.AjaxOutput;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import static org.ajax4jsf.renderkit.AjaxRendererUtils.ALL;
+import org.richfaces.log.RichfacesLogger;
+import org.slf4j.Logger;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.component.visit.VisitCallback;
@@ -45,155 +40,157 @@
import javax.faces.context.PartialViewContext;
import javax.faces.context.ResponseWriter;
import javax.faces.event.PhaseId;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
-import org.ajax4jsf.component.AjaxOutput;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.richfaces.log.RichfacesLogger;
-import org.slf4j.Logger;
-
/**
* @author Nick Belaevski
* @since 4.0
*/
public class PartialViewContextImpl extends PartialViewContext {
- private static final Logger LOG = RichfacesLogger.CONTEXT.getLogger();
-
- private static final String FACES_REQUEST_HEADER = "Faces-Request";
- private static final String PARTIAL_AJAX = "partial/ajax";
- private static final String PARTIAL_PROCESS = "partial/process";
-
- private static final String ORIGINAL_WRITER =
"org.richfaces.PartialViewContextImpl.ORIGINAL_WRITER";
-
- private FacesContext facesContext;
- private PartialResponseWriter partialResponseWriter;
+ private static final Logger LOG = RichfacesLogger.CONTEXT.getLogger();
- private Set<String> executeIds = null;
- private Set<String> renderIds = null;
-
- private Boolean ajaxRequest = null;
- private Boolean partialRequest = null;
- private Boolean renderAll = null;
+ private static final String FACES_REQUEST_HEADER = "Faces-Request";
+ private static final String PARTIAL_AJAX = "partial/ajax";
+ private static final String PARTIAL_PROCESS = "partial/process";
- private String activatorComponentId = null;
- private String behaviorEvent = null;
-
- private boolean released = false;
+ private static final String ORIGINAL_WRITER =
"org.richfaces.PartialViewContextImpl.ORIGINAL_WRITER";
- public PartialViewContextImpl(FacesContext facesContext, String activatorComponentId,
String behaviorEvent) {
- super();
-
- this.facesContext = facesContext;
-
- //activatorComponentId should not be null
- this.activatorComponentId = activatorComponentId;
- this.behaviorEvent = behaviorEvent;
- }
-
- @Override
- public Collection<String> getExecuteIds() {
- assertNotReleased();
+ private FacesContext facesContext;
+ private PartialResponseWriter partialResponseWriter;
- if (executeIds == null) {
- executeIds = new LinkedHashSet<String>();
-
- setupExecuteIds(executeIds);
- }
+ private Set<String> executeIds = null;
+ private Set<String> renderIds = null;
- return executeIds;
- }
+ private Boolean ajaxRequest = null;
+ private Boolean partialRequest = null;
+ private Boolean renderAll = null;
- @Override
- public Collection<String> getRenderIds() {
- assertNotReleased();
+ private String activatorComponentId = null;
+ private String behaviorEvent = null;
- if (renderIds == null) {
- renderIds = new LinkedHashSet<String>();
- }
+ private boolean released = false;
- return renderIds;
- }
+ public PartialViewContextImpl(FacesContext facesContext, String activatorComponentId,
String behaviorEvent) {
+ super();
- @Override
- public boolean isAjaxRequest() {
- assertNotReleased();
+ this.facesContext = facesContext;
- if (ajaxRequest == null) {
+ //activatorComponentId should not be null
+ this.activatorComponentId = activatorComponentId;
+ this.behaviorEvent = behaviorEvent;
+ }
+
+ @Override
+ public Collection<String> getExecuteIds() {
+ assertNotReleased();
+
+ if (executeIds == null) {
+ executeIds = new LinkedHashSet<String>();
+
+ setupExecuteIds(executeIds);
+ }
+
+ return executeIds;
+ }
+
+ @Override
+ public Collection<String> getRenderIds() {
+ assertNotReleased();
+
+ if (renderIds == null) {
+ renderIds = new LinkedHashSet<String>();
+ }
+
+ return renderIds;
+ }
+
+ @Override
+ public boolean isAjaxRequest() {
+ assertNotReleased();
+
+ if (ajaxRequest == null) {
Map<String, String> requestHeaderMap =
facesContext.getExternalContext().getRequestHeaderMap();
- ajaxRequest = PARTIAL_AJAX.equals(requestHeaderMap.get(FACES_REQUEST_HEADER));
- }
-
- return ajaxRequest.booleanValue();
- }
+ ajaxRequest =
PARTIAL_AJAX.equals(requestHeaderMap.get(FACES_REQUEST_HEADER));
+ }
- @Override
- public boolean isPartialRequest() {
- assertNotReleased();
+ return ajaxRequest.booleanValue();
+ }
- if (partialRequest == null) {
+ @Override
+ public boolean isPartialRequest() {
+ assertNotReleased();
+
+ if (partialRequest == null) {
if (isAjaxRequest()) {
- partialRequest = true;
+ partialRequest = true;
} else {
- Map<String, String> requestHeaderMap =
facesContext.getExternalContext().getRequestHeaderMap();
- partialRequest =
PARTIAL_PROCESS.equals(requestHeaderMap.get(FACES_REQUEST_HEADER));
+ Map<String, String> requestHeaderMap =
facesContext.getExternalContext().getRequestHeaderMap();
+ partialRequest =
PARTIAL_PROCESS.equals(requestHeaderMap.get(FACES_REQUEST_HEADER));
}
- }
-
- return partialRequest.booleanValue();
- }
+ }
- @Override
- public void setPartialRequest(boolean isPartialRequest) {
- assertNotReleased();
+ return partialRequest.booleanValue();
+ }
- partialRequest = isPartialRequest;
- }
+ @Override
+ public void setPartialRequest(boolean isPartialRequest) {
+ assertNotReleased();
+ partialRequest = isPartialRequest;
+ }
- @Override
- public boolean isExecuteAll() {
- assertNotReleased();
+ @Override
+ public boolean isExecuteAll() {
+ assertNotReleased();
- return getExecuteIds().contains(ALL);
- }
+ return getExecuteIds().contains(ALL);
+ }
- @Override
- public boolean isRenderAll() {
- assertNotReleased();
+ @Override
+ public boolean isRenderAll() {
+ assertNotReleased();
- if (renderAll == null) {
- renderAll = getRenderIds().contains(ALL);
- }
-
- return renderAll;
- }
+ if (renderAll == null) {
+ renderAll = getRenderIds().contains(ALL);
+ }
- @Override
- public void setRenderAll(boolean isRenderAll) {
- assertNotReleased();
+ return renderAll;
+ }
- renderAll = isRenderAll;
- }
+ @Override
+ public void setRenderAll(boolean isRenderAll) {
+ assertNotReleased();
- @Override
- public PartialResponseWriter getPartialResponseWriter() {
- assertNotReleased();
+ renderAll = isRenderAll;
+ }
- if (partialResponseWriter == null) {
- partialResponseWriter = new PartialDelayedInitializationResponseWriter(facesContext);
- }
-
- return partialResponseWriter;
- }
+ @Override
+ public PartialResponseWriter getPartialResponseWriter() {
+ assertNotReleased();
- @Override
- public void processPartial(PhaseId phaseId) {
+ if (partialResponseWriter == null) {
+ partialResponseWriter = new
PartialDelayedInitializationResponseWriter(facesContext);
+ }
+
+ return partialResponseWriter;
+ }
+
+ @Override
+ public void processPartial(PhaseId phaseId) {
UIViewRoot viewRoot = facesContext.getViewRoot();
- if (phaseId == PhaseId.APPLY_REQUEST_VALUES ||
- phaseId == PhaseId.PROCESS_VALIDATIONS ||
- phaseId == PhaseId.UPDATE_MODEL_VALUES) {
+ if (phaseId == PhaseId.APPLY_REQUEST_VALUES
+ || phaseId == PhaseId.PROCESS_VALIDATIONS
+ || phaseId == PhaseId.UPDATE_MODEL_VALUES) {
Collection<String> ids = getExecuteIds();
@@ -203,7 +200,7 @@
// RELEASE_PENDING LOG ERROR OR WARNING
return;
}
-
+
try {
processComponents(viewRoot, phaseId, ids, facesContext);
} catch (Exception e) {
@@ -221,9 +218,9 @@
}
} else if (phaseId == PhaseId.RENDER_RESPONSE) {
Collection<String> ids = getRenderIds();
- setupRenderIds(ids);
-
- try {
+ setupRenderIds(ids);
+
+ try {
PartialResponseWriter writer = getPartialResponseWriter();
ResponseWriter orig = facesContext.getResponseWriter();
facesContext.getAttributes().put(ORIGINAL_WRITER, orig);
@@ -239,16 +236,15 @@
writer.endDocument();
return;
}
-
+
// Skip this processing if "none" is specified in the render
list,
// or there were no render phase client ids.
- if (ids == null || ids.isEmpty()) {
- } else {
+ if (ids != null && !ids.isEmpty()) {
processComponents(viewRoot, phaseId, ids, facesContext);
}
renderState(facesContext);
-
+
//TODO - render extensions for renderAll?
renderExtensions(facesContext, viewRoot);
@@ -263,48 +259,48 @@
throw ex;
}
}
- }
-
- private void setupExecuteIds(Collection<String> ids) {
- ExecuteComponentCallback callback = new ExecuteComponentCallback(behaviorEvent);
+ }
- if (visitActivatorComponent(activatorComponentId, callback)) {
- ids.addAll(callback.getComponentIds());
-
- if (!ids.contains(ALL)) {
- addImplicitExecuteIds(ids);
- }
- } else {
- //TODO - log or exception?
- //TODO - process default execute value
- }
- }
-
- private void setupRenderIds(Collection<String> ids) {
- if (!isRenderAll()) {
- RenderComponentCallback callback = new RenderComponentCallback(behaviorEvent);
-
- if (visitActivatorComponent(activatorComponentId, callback)) {
- ids.addAll(callback.getComponentIds());
+ private void setupExecuteIds(Collection<String> ids) {
+ ExecuteComponentCallback callback = new ExecuteComponentCallback(behaviorEvent);
- if (!Boolean.TRUE.equals(renderAll) && !ids.contains(ALL)) {
- addImplicitRenderIds(ids, callback.isLimitRender());
-
- //TODO - review
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
- ajaxContext.setOnbeforedomupdate(callback.getOnbeforedomupdate());
- ajaxContext.setOncomplete(callback.getOncomplete());
- ajaxContext.setResponseData(callback.getData());
- }
- } else {
- //TODO - the same as for "execute"
- }
- }
- }
-
+ if (visitActivatorComponent(activatorComponentId, callback)) {
+ ids.addAll(callback.getComponentIds());
+
+ if (!ids.contains(ALL)) {
+ addImplicitExecuteIds(ids);
+ }
+ } else {
+ //TODO - log or exception?
+ //TODO - process default execute value
+ }
+ }
+
+ private void setupRenderIds(Collection<String> ids) {
+ if (!isRenderAll()) {
+ RenderComponentCallback callback = new
RenderComponentCallback(behaviorEvent);
+
+ if (visitActivatorComponent(activatorComponentId, callback)) {
+ ids.addAll(callback.getComponentIds());
+
+ if (!Boolean.TRUE.equals(renderAll) && !ids.contains(ALL)) {
+ addImplicitRenderIds(ids, callback.isLimitRender());
+
+ //TODO - review
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
+ ajaxContext.setOnbeforedomupdate(callback.getOnbeforedomupdate());
+ ajaxContext.setOncomplete(callback.getOncomplete());
+ ajaxContext.setResponseData(callback.getData());
+ }
+ } else {
+ //TODO - the same as for "execute"
+ }
+ }
+ }
+
// Process the components specified in the phaseClientIds list
private void processComponents(UIComponent component, PhaseId phaseId,
- Collection<String> phaseClientIds, FacesContext context) throws IOException
{
+ Collection<String> phaseClientIds, FacesContext
context) throws IOException {
// We use the tree visitor mechanism to locate the components to
// process. Create our (partial) VisitContext and the
@@ -351,80 +347,80 @@
*
* @see javax.faces.context.PartialViewContext#release()
*/
- @Override
- public void release() {
- assertNotReleased();
+ @Override
+ public void release() {
+ assertNotReleased();
- released = true;
-
- facesContext = null;
- partialResponseWriter = null;
-
- executeIds = null;
- renderIds = null;
-
- ajaxRequest = null;
- partialRequest = null;
- renderAll = null;
-
- activatorComponentId = null;
- behaviorEvent = null;
- }
+ released = true;
- protected void addImplicitExecuteIds(Collection<String> ids) {
- if (!ids.isEmpty()) {
- UIViewRoot root = facesContext.getViewRoot();
- if (root.getFacetCount() > 0) {
- if (root.getFacet(UIViewRoot.METADATA_FACET_NAME) != null) {
- ids.add(UIViewRoot.METADATA_FACET_NAME);
- }
- }
- }
- }
-
- protected void addImplicitRenderIds(Collection<String> ids, boolean limitRender)
{
- if (!limitRender) {
- // TODO: data table support
- Collection<AjaxOutput> ajaxOutputComponentsSet =
-
PartialViewContextAjaxOutputTracker.getAjaxOutputComponentsSet(facesContext);
+ facesContext = null;
+ partialResponseWriter = null;
- for (AjaxOutput ajaxOutput : ajaxOutputComponentsSet) {
- if (ajaxOutput.isAjaxRendered()) {
- UIComponent ajaxOutputComponent = (UIComponent) ajaxOutput;
+ executeIds = null;
+ renderIds = null;
- ids.add(ajaxOutputComponent.getClientId(facesContext));
- }
- }
- }
- }
+ ajaxRequest = null;
+ partialRequest = null;
+ renderAll = null;
- protected void renderExtensions(FacesContext context, UIComponent component) throws
IOException {
- AjaxRendererUtils.renderAjaxExtensions(context, component);
- }
-
- private void assertNotReleased() {
- if (released) {
- throw new IllegalStateException("PartialViewContext already released!");
- }
- }
-
- private boolean visitActivatorComponent(String componentActivatorId, VisitCallback
visitCallback) {
+ activatorComponentId = null;
+ behaviorEvent = null;
+ }
+
+ protected void addImplicitExecuteIds(Collection<String> ids) {
+ if (!ids.isEmpty()) {
+ UIViewRoot root = facesContext.getViewRoot();
+ if (root.getFacetCount() > 0) {
+ if (root.getFacet(UIViewRoot.METADATA_FACET_NAME) != null) {
+ ids.add(UIViewRoot.METADATA_FACET_NAME);
+ }
+ }
+ }
+ }
+
+ protected void addImplicitRenderIds(Collection<String> ids, boolean
limitRender) {
+ if (!limitRender) {
+ // TODO: data table support
+ Collection<AjaxOutput> ajaxOutputComponentsSet =
+
PartialViewContextAjaxOutputTracker.getAjaxOutputComponentsSet(facesContext);
+
+ for (AjaxOutput ajaxOutput : ajaxOutputComponentsSet) {
+ if (ajaxOutput.isAjaxRendered()) {
+ UIComponent ajaxOutputComponent = (UIComponent) ajaxOutput;
+
+ ids.add(ajaxOutputComponent.getClientId(facesContext));
+ }
+ }
+ }
+ }
+
+ protected void renderExtensions(FacesContext context, UIComponent component) throws
IOException {
+ AjaxRendererUtils.renderAjaxExtensions(context, component);
+ }
+
+ private void assertNotReleased() {
+ if (released) {
+ throw new IllegalStateException("PartialViewContext already
released!");
+ }
+ }
+
+ private boolean visitActivatorComponent(String componentActivatorId, VisitCallback
visitCallback) {
Set<String> idsToVisit = Collections.singleton(componentActivatorId);
- Set<VisitHint> visitHints = EnumSet.of(VisitHint.SKIP_UNRENDERED);
- VisitContext visitContext = VisitContext.createVisitContext(facesContext, idsToVisit,
visitHints);
+ Set<VisitHint> visitHints = EnumSet.of(VisitHint.SKIP_UNRENDERED);
+ VisitContext visitContext = VisitContext.createVisitContext(facesContext,
idsToVisit, visitHints);
- boolean visitResult = facesContext.getViewRoot().visitTree(visitContext,
visitCallback);
- return visitResult;
- }
-
+ boolean visitResult = facesContext.getViewRoot().visitTree(visitContext,
visitCallback);
+ return visitResult;
+ }
+
private void cleanupAfterView() {
ResponseWriter orig = (ResponseWriter)
facesContext.getAttributes().get(ORIGINAL_WRITER);
- assert (null != orig);
+ assert null != orig;
// move aside the PartialResponseWriter
facesContext.setResponseWriter(orig);
}
- private static class PhaseAwareVisitCallback implements VisitCallback {
+ private static final class PhaseAwareVisitCallback implements VisitCallback {
private PhaseId curPhase;
private FacesContext ctx;
@@ -432,9 +428,8 @@
private PhaseAwareVisitCallback(FacesContext ctx, PhaseId curPhase) {
this.ctx = ctx;
this.curPhase = curPhase;
- }
+ }
-
public VisitResult visit(VisitContext context, UIComponent comp) {
try {
if (curPhase == PhaseId.APPLY_REQUEST_VALUES) {
@@ -456,8 +451,7 @@
try {
// do the default behavior...
comp.encodeAll(ctx);
- }
- catch (Exception ce) {
+ } catch (Exception ce) {
if (LOG.isErrorEnabled()) {
LOG.error(ce.getMessage());
}
@@ -466,13 +460,10 @@
}
}
writer.endUpdate();
+ } else {
+ throw new IllegalStateException("I18N: Unexpected "
+ + "PhaseId passed to PhaseAwareContextCallback: " +
curPhase.toString());
}
- else {
- throw new IllegalStateException("I18N: Unexpected " +
- "PhaseId passed to " +
- " PhaseAwareContextCallback: " +
- curPhase.toString());
- }
} catch (IOException ex) {
ex.printStackTrace();
}
@@ -485,57 +476,55 @@
}
}
-
private static final class PartialDelayedInitializationResponseWriter extends
PartialResponseWriter {
- private static final String DEFAULT_CHARACTER_ENCODING = "ISO-8859-1";
+ private static final String DEFAULT_CHARACTER_ENCODING = "ISO-8859-1";
- private FacesContext facesContext;
+ private FacesContext facesContext;
- private ResponseWriter responseWriter;
-
- /**
- * @param writer
- */
- public PartialDelayedInitializationResponseWriter(FacesContext facesContext) {
- super(null);
- this.facesContext = facesContext;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.context.PartialResponseWriter#getWrapped()
- */
- @Override
- public ResponseWriter getWrapped() {
- if (responseWriter == null) {
- responseWriter = createResponseWriter();
- }
-
- return responseWriter;
- }
-
- private ResponseWriter createResponseWriter() {
- ResponseWriter newResponseWriter = null;
- ExternalContext externalContext = facesContext.getExternalContext();
- String characterEncoding = externalContext.getRequestCharacterEncoding();
-
- if (characterEncoding == null) {
- characterEncoding = DEFAULT_CHARACTER_ENCODING;
- }
-
- externalContext.setResponseCharacterEncoding(characterEncoding);
-
- Writer outputWriter = null;
- try {
- outputWriter = facesContext.getExternalContext().getResponseOutputWriter();
- } catch (IOException e) {
- LOG.error("Error creating partial context response writer: " +
e.getMessage(), e);
- }
-
- newResponseWriter = facesContext.getRenderKit().
- createResponseWriter(outputWriter, "text/xml", characterEncoding);
+ private ResponseWriter responseWriter;
- return newResponseWriter;
- }
- }
+ /**
+ * @param facesContext
+ */
+ public PartialDelayedInitializationResponseWriter(FacesContext facesContext) {
+ super(null);
+ this.facesContext = facesContext;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.context.PartialResponseWriter#getWrapped()
+ */
+ @Override
+ public ResponseWriter getWrapped() {
+ if (responseWriter == null) {
+ responseWriter = createResponseWriter();
+ }
+
+ return responseWriter;
+ }
+
+ private ResponseWriter createResponseWriter() {
+ ExternalContext externalContext = facesContext.getExternalContext();
+ String characterEncoding = externalContext.getRequestCharacterEncoding();
+
+ if (characterEncoding == null) {
+ characterEncoding = DEFAULT_CHARACTER_ENCODING;
+ }
+
+ externalContext.setResponseCharacterEncoding(characterEncoding);
+
+ Writer outputWriter = null;
+ try {
+ outputWriter =
facesContext.getExternalContext().getResponseOutputWriter();
+ } catch (IOException e) {
+ LOG.error("Error creating partial context response writer: " +
e.getMessage(), e);
+ }
+
+ ResponseWriter newResponseWriter = facesContext.getRenderKit().
+ createResponseWriter(outputWriter, "text/xml",
characterEncoding);
+
+ return newResponseWriter;
+ }
+ }
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.context;
import org.ajax4jsf.component.AjaxClientBehavior;
@@ -34,16 +32,16 @@
* @since Oct 13, 2009
*/
class RenderComponentCallback extends ComponentCallback {
-
- private boolean limitRender = false;
- private String oncomplete;
-
- private String onbeforedomupdate;
+ private boolean limitRender = false;
- private Object data;
-
- RenderComponentCallback(String behaviorEvent) {
+ private String oncomplete;
+
+ private String onbeforedomupdate;
+
+ private Object data;
+
+ RenderComponentCallback(String behaviorEvent) {
super(behaviorEvent, null);
}
@@ -51,27 +49,27 @@
return limitRender;
}
- public String getOnbeforedomupdate() {
- return onbeforedomupdate;
- }
-
- public String getOncomplete() {
- return oncomplete;
- }
-
- public Object getData() {
- return data;
- }
+ public String getOnbeforedomupdate() {
+ return onbeforedomupdate;
+ }
- @Override
+ public String getOncomplete() {
+ return oncomplete;
+ }
+
+ public Object getData() {
+ return data;
+ }
+
+ @Override
protected void doVisit(FacesContext context, UIComponent target, AjaxClientBehavior
behavior) {
super.doVisit(context, target, behavior);
-
+
limitRender = AjaxRendererUtils.isAjaxLimitRender(target);
onbeforedomupdate = AjaxRendererUtils.getAjaxOnBeforeDomUpdate(target);
oncomplete = AjaxRendererUtils.getAjaxOncomplete(target);
data = AjaxRendererUtils.getAjaxData(target);
-
+
if (behavior != null) {
limitRender = behavior.isLimitRender();
onbeforedomupdate = behavior.getOnbeforedomupdate();
@@ -89,5 +87,5 @@
protected Object getBehaviorAttributeValue(AjaxClientBehavior behavior) {
return behavior.getRender();
}
-
+
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/SingletonsContext.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/context/SingletonsContext.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/context/SingletonsContext.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,14 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.context;
+import javax.faces.context.FacesContext;
import java.util.Map;
-import javax.faces.context.FacesContext;
-
/**
* @author Nick Belaevski
* @since 4.0
@@ -45,5 +42,6 @@
}
};
- private SingletonsContext() {}
+ private SingletonsContext() {
+ }
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/event/SwitchablePanelSwitchEvent.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/event/SwitchablePanelSwitchEvent.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/event/SwitchablePanelSwitchEvent.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.event;
import javax.faces.component.UIComponent;
@@ -29,8 +27,7 @@
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 23.01.2007
- *
+ * created 23.01.2007
*/
public class SwitchablePanelSwitchEvent extends FacesEvent {
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/event/package-info.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/event/package-info.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/event/package-info.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -1,4 +1,3 @@
-
/**
* Base RichFaces component events classes
*/
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/CDL.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/CDL.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/CDL.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -29,26 +29,29 @@
* JSONArray, and to covert a JSONArray into comma delimited text. Comma
* delimited text is a very popular format for data interchange. It is
* understood by most database, spreadsheet, and organizer programs.
- * <p>
+ * <p/>
* Each row of text represents a row in a table or a data record. Each row
* ends with a NEWLINE character. Each row contains one or more values.
* Values are separated by commas. A value can contain any character except
* for comma, unless is is wrapped in single quotes or double quotes.
- * <p>
+ * <p/>
* The first row usually contains the names of the columns.
- * <p>
+ * <p/>
* A comma delimited list can be converted into a JSONArray of JSONObjects.
* The names for the elements in the JSONObjects can be taken from the names
* in the first row.
+ *
* @author
JSON.org
* @version 2
*/
public final class CDL {
- private CDL() {}
+ private CDL() {
+ }
/**
* Get the next value. The value can be wrapped in quotes. The value can
* be empty.
+ *
* @param x A JSONTokener of the source text.
* @return The value string, or null if empty.
* @throws JSONException if the quoted string is badly formed.
@@ -61,19 +64,19 @@
} while ((c <= ' ') && (c != 0));
switch (c) {
- case 0 :
+ case 0:
return null;
- case '"' :
- case '\'' :
+ case '"':
+ case '\'':
return x.nextString(c);
- case ',' :
+ case ',':
x.back();
return "";
- default :
+ default:
x.back();
return x.nextTo(',');
@@ -82,6 +85,7 @@
/**
* Produce a JSONArray of strings from a row of comma delimited values.
+ *
* @param x A JSONTokener of the source text.
* @return A JSONArray of strings.
* @throws JSONException
@@ -119,10 +123,11 @@
/**
* Produce a JSONObject from a row of comma delimited text, using a
* parallel JSONArray of strings to provides the names of the elements.
+ *
* @param names A JSONArray of names. This is commonly obtained from the
- * first row of a comma delimited text file using the rowToJSONArray
- * method.
- * @param x A JSONTokener of the source text.
+ * first row of a comma delimited text file using the rowToJSONArray
+ * method.
+ * @param x A JSONTokener of the source text.
* @return A JSONObject combining the names and values.
* @throws JSONException
*/
@@ -135,6 +140,7 @@
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string,
* using the first row as a source of names.
+ *
* @param string The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
@@ -146,6 +152,7 @@
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string,
* using the first row as a source of names.
+ *
* @param x The JSONTokener containing the comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
@@ -157,7 +164,8 @@
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string
* using a supplied JSONArray as the source of element names.
- * @param names A JSONArray of strings.
+ *
+ * @param names A JSONArray of strings.
* @param string The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
@@ -169,8 +177,9 @@
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string
* using a supplied JSONArray as the source of element names.
+ *
* @param names A JSONArray of strings.
- * @param x A JSONTokener of the source text.
+ * @param x A JSONTokener of the source text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
@@ -201,6 +210,7 @@
/**
* Produce a comma delimited text row from a JSONArray. Values containing
* the comma character will be quoted.
+ *
* @param ja A JSONArray of strings.
* @return A string ending in NEWLINE.
*/
@@ -242,6 +252,7 @@
* Produce a comma delimited text from a JSONArray of JSONObjects. The
* first row will be a list of names obtained by inspecting the first
* JSONObject.
+ *
* @param ja A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
@@ -264,8 +275,9 @@
* Produce a comma delimited text from a JSONArray of JSONObjects using
* a provided list of names. The list of names is not included in the
* output.
+ *
* @param names A JSONArray of strings.
- * @param ja A JSONArray of JSONObjects.
+ * @param ja A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
*/
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/Cookie.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/Cookie.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/Cookie.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -27,11 +27,13 @@
/**
* Convert a web browser cookie specification to a JSONObject and back.
* JSON and Cookies are both notations for name/value pairs.
+ *
* @author
JSON.org
* @version 2
*/
public final class Cookie {
- private Cookie() {}
+ private Cookie() {
+ }
/**
* Produce a copy of a string in which the characters '+', '%',
'=', ';'
@@ -42,8 +44,9 @@
* only a convention, not a standard. Often, cookies are expected to have
* encoded values. We encode '=' and ';' because we must. We encode
'%' and
* '+' because they are meta characters in URL encoding.
+ *
* @param string The source string.
- * @return The escaped result.
+ * @return The escaped result.
*/
public static String escape(String string) {
char c;
@@ -76,9 +79,10 @@
* stored under the key "value". This method does not do checking or
* validation of the parameters. It only converts the cookie string into
* a JSONObject.
+ *
* @param string The cookie specification string.
* @return A JSONObject containing "name", "value", and possibly
other
- * members.
+ * members.
* @throws JSONException
*/
public static JSONObject toJSONObject(String string) throws JSONException {
@@ -118,6 +122,7 @@
* If the JSONObject contains "expires", "domain",
"path", or "secure"
* members, they will be appended to the cookie specification string.
* All other members are ignored.
+ *
* @param o A JSONObject
* @return A cookie specification string
* @throws JSONException
@@ -154,9 +159,10 @@
/**
* Convert <code>%</code><i>hh</i> sequences to single
characters, and
* convert plus to space.
+ *
* @param s A string that may contain
- * <code>+</code> <small>(plus)</small> and
- * <code>%</code><i>hh</i> sequences.
+ * <code>+</code> <small>(plus)</small>
and
+ * <code>%</code><i>hh</i> sequences.
* @return The unescaped string.
*/
public static String unescape(String s) {
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/CookieList.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/CookieList.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/CookieList.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -23,26 +23,30 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
+
import java.util.Iterator;
/**
* Convert a web browser cookie list string to a JSONObject and back.
+ *
* @author
JSON.org
* @version 2
*/
public final class CookieList {
- private CookieList() {}
+ private CookieList() {
+ }
/**
* Convert a cookie list into a JSONObject. A cookie list is a sequence
* of name/value pairs. The names are separated from the values by '='.
* The pairs are separated by ';'. The names and the values
* will be unescaped, possibly converting '+' and '%' sequences.
- *
+ * <p/>
* To add a cookie to a cooklist,
* cookielistJSONObject.put(cookieJSONObject.getString("name"),
- * cookieJSONObject.getString("value"));
- * @param string A cookie list string
+ * cookieJSONObject.getString("value"));
+ *
+ * @param string A cookie list string
* @return A JSONObject
* @throws JSONException
*/
@@ -66,6 +70,7 @@
* of name/value pairs. The names are separated from the values by '='.
* The pairs are separated by ';'. The characters '%', '+',
'=', and ';'
* in the names and values are replaced by "%hh".
+ *
* @param o A JSONObject
* @return A cookie list string
* @throws JSONException
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/HTTP.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/HTTP.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/HTTP.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -23,10 +23,12 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
+
import java.util.Iterator;
/**
* Convert an HTTP header to a JSONObject and back.
+ *
* @author
JSON.org
* @version 2
*/
@@ -37,7 +39,8 @@
*/
public static final String CRLF = "\r\n";
- private HTTP() {}
+ private HTTP() {
+ }
/**
* Convert an HTTP header string into a JSONObject. It can be a request
@@ -66,9 +69,10 @@
* ...}</pre>
* It does no further checking or conversion. It does not parse dates.
* It does not do '%' transforms on URLs.
+ *
* @param string An HTTP header string.
* @return A JSONObject containing the elements and attributes
- * of the XML string.
+ * of the XML string.
* @throws JSONException
*/
public static JSONObject toJSONObject(String string) throws JSONException {
@@ -120,10 +124,11 @@
* }</pre>
* Any other members of the JSONObject will be output as HTTP fields.
* The result will end with two CRLF pairs.
+ *
* @param o A JSONObject
* @return An HTTP header string.
* @throws JSONException if the object does not contain enough
- * information.
+ * information.
*/
public static String toString(JSONObject o) throws JSONException {
Iterator keys = o.keys();
@@ -154,7 +159,7 @@
s = keys.next().toString();
if (!s.equals("HTTP-Version") &&
!s.equals("Status-Code") && !s.equals("Reason-Phrase")
- && !s.equals("Method") &&
!s.equals("Request-URI") && !o.isNull(s)) {
+ && !s.equals("Method") &&
!s.equals("Request-URI") && !o.isNull(s)) {
sb.append(s);
sb.append(": ");
sb.append(o.getString(s));
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/HTTPTokener.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/HTTPTokener.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/HTTPTokener.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -27,6 +27,7 @@
/**
* The HTTPTokener extends the JSONTokener to provide additional methods
* for the parsing of HTTP headers.
+ *
* @author
JSON.org
* @version 2
*/
@@ -34,6 +35,7 @@
/**
* Construct an XMLTokener from a string.
+ *
* @param s A source string.
*/
public HTTPTokener(String s) {
@@ -42,8 +44,9 @@
/**
* Get the next token or string. This is used in parsing HTTP headers.
+ *
+ * @return A String.
* @throws JSONException
- * @return A String.
*/
public String nextToken() throws JSONException {
char c;
@@ -57,7 +60,7 @@
if ((c == '"') || (c == '\'')) {
q = c;
- for (;;) {
+ for (; ;) {
c = next();
if (c < ' ') {
@@ -72,7 +75,7 @@
}
}
- for (;;) {
+ for (; ;) {
if ((c == 0) || Character.isWhitespace(c)) {
return sb.toString();
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSContentHandler.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSContentHandler.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSContentHandler.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,13 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.json;
import org.ajax4jsf.Messages;
import org.ajax4jsf.javascript.JSEncoder;
-
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
@@ -34,21 +31,21 @@
import java.io.IOException;
import java.io.Writer;
-
import java.util.Arrays;
/**
* @author shura
- * SAX content handler for serialise events as JavaScript function.
+ * SAX content handler for serialise events as JavaScript function.
*/
public class JSContentHandler implements ContentHandler, LexicalHandler {
+ public static final String DEFAULT_ENCODING = "ISO-8859-1";
+
private static final char C_COMMA = ',';
private static final char C_GT = '>';
private static final char C_LT = '<';
private static final char C_NSSEP = ':';
private static final char C_QUOTE = '\'';
private static final char C_SPACE = ' ';
- public static final String DEFAULT_ENCODING = "ISO-8859-1";
private static final JSEncoder ENCODER = new JSEncoder();
private static final char[] S_TEXT_START = "new T(".toCharArray();
private static final char[] S_TEXT_END = ")".toCharArray();
@@ -71,28 +68,39 @@
private static final char[] S_ATTRIBUTES_START = ",{".toCharArray();
private static final char[] S_ATTRIBUTES_END = "}".toCharArray();
private static final boolean DEBUG = false;
+
+ // protected DocType doctype = null;
+ protected char[] indentBuffer;
+ protected int level;
+
+ protected Writer outputWriter;
+
private boolean hangingElement = false;
- /** True if we are processing the prolog. */
+ /**
+ * True if we are processing the prolog.
+ */
private boolean beforeDocumentStart = true;
- /** True if we are processing the DTD. */
+ /**
+ * True if we are processing the DTD.
+ */
private boolean processingDtd = false;
- /** True if we are processing the DTD. */
+ /**
+ * True if we are processing the DTD.
+ */
private boolean processingCdata = false;
/* ====================================================================== */
- // protected DocType doctype = null;
- protected char[] indentBuffer;
- protected int level;
-
- /** The <code>DocType</code> instance representing the document. */
+ /**
+ * The <code>DocType</code> instance representing the document.
+ */
private Locator locator;
- protected Writer outputWriter;
- public JSContentHandler() {}
+ public JSContentHandler() {
+ }
/**
* @param outputWriter
@@ -114,6 +122,7 @@
* (non-Javadoc)
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
*/
+
public void characters(char[] ch, int start, int length) throws SAXException {
if (this.beforeDocumentStart || (level < 0)) {
return;
@@ -196,9 +205,8 @@
/**
* Write the end part of a start element (if necessary).
*
- * @param endElement
- * Whether this method was called because an element is being
- * closed or not.
+ * @param endElement Whether this method was called because an element is being
+ * closed or not.
* @return <b>true </b> if this call successfully closed the element (and
no
* further <code></element></code> is required.
*/
@@ -226,7 +234,8 @@
* (non-Javadoc)
* @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
*/
- public void endPrefixMapping(String prefix) throws SAXException {}
+ public void endPrefixMapping(String prefix) throws SAXException {
+ }
/*
* (non-Javadoc)
@@ -321,6 +330,7 @@
* (non-Javadoc)
* @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
*/
+
public void skippedEntity(String name) throws SAXException {
// TODO Auto-generated method stub
@@ -443,7 +453,8 @@
* (non-Javadoc)
* @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String,
java.lang.String)
*/
- public void startPrefixMapping(String prefix, String uri) throws SAXException {}
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ }
/*
* (non-Javadoc)
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONAccessor.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONAccessor.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONAccessor.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,15 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.json;
import java.util.Collection;
import java.util.Map;
final class JSONAccessor {
- private JSONAccessor() {}
+ private JSONAccessor() {
+ }
static boolean putValue(JSONObject object, String key, Object value) {
try {
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONArray.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONArray.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONArray.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -23,10 +23,10 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
+
import java.io.IOException;
import java.io.Serializable;
import java.io.Writer;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
@@ -40,42 +40,42 @@
* <code>Boolean</code>, <code>JSONArray</code>,
<code>JSONObject</code>,
* <code>Number</code>, <code>String</code>, or the
* <code>JSONObject.NULL object</code>.
- * <p>
+ * <p/>
* The constructor can convert a JSON text into a Java object. The
* <code>toString</code> method converts to JSON text.
- * <p>
+ * <p/>
* A <code>get</code> method returns a value if one can be found, and throws
an
* exception if one cannot be found. An <code>opt</code> method returns a
* default value instead of throwing an exception, and so is useful for
* obtaining optional values.
- * <p>
+ * <p/>
* The generic <code>get()</code> and <code>opt()</code> methods
return an
* object which you can cast or query for type. There are also typed
* <code>get</code> and <code>opt</code> methods that do type
checking and type
* coersion for you.
- * <p>
+ * <p/>
* The texts produced by the <code>toString</code> methods strictly conform
to
* JSON syntax rules. The constructors are more forgiving in the texts they will
* accept:
* <ul>
* <li>An extra
<code>,</code> <small>(comma)</small> may appear just
- * before the closing bracket.</li>
+ * before the closing bracket.</li>
* <li>The <code>null</code> value will be inserted when there
- * is <code>,</code> <small>(comma)</small>
elision.</li>
+ * is <code>,</code> <small>(comma)</small>
elision.</li>
* <li>Strings may be quoted with
<code>'</code> <small>(single
- * quote)</small>.</li>
+ * quote)</small>.</li>
* <li>Strings do not need to be quoted at all if they do not begin with a quote
- * or single quote, and if they do not contain leading or trailing spaces,
- * and if they do not contain any of these characters:
- * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like
numbers
- * and if they are not the reserved words <code>true</code>,
- * <code>false</code>, or <code>null</code>.</li>
+ * or single quote, and if they do not contain leading or trailing spaces,
+ * and if they do not contain any of these characters:
+ * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers
+ * and if they are not the reserved words <code>true</code>,
+ * <code>false</code>, or <code>null</code>.</li>
* <li>Values can be separated by <code>;</code>
<small>(semicolon)</small> as
- * well as by <code>,</code>
<small>(comma)</small>.</li>
+ * well as by <code>,</code> <small>(comma)</small>.</li>
* <li>Numbers may have the <code>0-</code>
<small>(octal)</small> or
- * <code>0x-</code> <small>(hex)</small> prefix.</li>
+ * <code>0x-</code> <small>(hex)</small> prefix.</li>
* <li>Comments written in the slashshlash, slashstar, and hash conventions
- * will be ignored.</li>
+ * will be ignored.</li>
* </ul>
*
* @author
JSON.org
@@ -102,7 +102,8 @@
/**
* Construct a JSONArray from a Collection.
- * @param collection A Collection.
+ *
+ * @param collection A Collection.
*/
public JSONArray(Collection collection) {
this.myArrayList = (collection == null) ? new ArrayList() : new
ArrayList(collection);
@@ -110,6 +111,7 @@
/**
* Construct a JSONArray from a JSONTokener.
+ *
* @param x A JSONTokener
* @throws JSONException If there is a syntax error.
*/
@@ -136,8 +138,8 @@
}
switch (x.nextClean()) {
- case ';' :
- case ',' :
+ case ';':
+ case ',':
if (x.nextClean() == ']') {
return;
}
@@ -146,10 +148,10 @@
break;
- case ']' :
+ case ']':
return;
- default :
+ default:
throw x.syntaxError("Expected a ',' or
']'");
}
}
@@ -157,10 +159,11 @@
/**
* Construct a JSONArray from a source sJSON text.
- * @param string A string that begins with
- * <code>[</code> <small>(left bracket)</small>
- * and ends with <code>]</code> <small>(right
bracket)</small>.
- * @throws JSONException If there is a syntax error.
+ *
+ * @param string A string that begins with
+ * <code>[</code> <small>(left
bracket)</small>
+ * and ends with
<code>]</code> <small>(right bracket)</small>.
+ * @throws JSONException If there is a syntax error.
*/
public JSONArray(String string) throws JSONException {
this(new JSONTokener(string));
@@ -168,8 +171,8 @@
/**
* Get the object value associated with an index.
- * @param index
- * The index must be between 0 and length() - 1.
+ *
+ * @param index The index must be between 0 and length() - 1.
* @return An object value.
* @throws JSONException If there is no value for the index.
*/
@@ -188,9 +191,9 @@
* The string values "true" and "false" are converted to
boolean.
*
* @param index The index must be between 0 and length() - 1.
- * @return The truth.
+ * @return The truth.
* @throws JSONException If there is no value for the index or if the
- * value is not convertable to boolean.
+ * value is not convertable to boolean.
*/
public boolean getBoolean(int index) throws JSONException {
Object o = get(index);
@@ -208,9 +211,9 @@
* Get the double value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
- * @return The value.
- * @throws JSONException If the key is not found or if the value cannot
- * be converted to a number.
+ * @return The value.
+ * @throws JSONException If the key is not found or if the value cannot
+ * be converted to a number.
*/
public double getDouble(int index) throws JSONException {
Object o = get(index);
@@ -226,10 +229,10 @@
* Get the int value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
- * @return The value.
- * @throws JSONException If the key is not found or if the value cannot
- * be converted to a number.
- * if the value cannot be converted to a number.
+ * @return The value.
+ * @throws JSONException If the key is not found or if the value cannot
+ * be converted to a number.
+ * if the value cannot be converted to a number.
*/
public int getInt(int index) throws JSONException {
Object o = get(index);
@@ -239,10 +242,11 @@
/**
* Get the JSONArray associated with an index.
+ *
* @param index The index must be between 0 and length() - 1.
- * @return A JSONArray value.
+ * @return A JSONArray value.
* @throws JSONException If there is no value for the index. or if the
- * value is not a JSONArray
+ * value is not a JSONArray
*/
public JSONArray getJSONArray(int index) throws JSONException {
Object o = get(index);
@@ -256,10 +260,11 @@
/**
* Get the JSONObject associated with an index.
+ *
* @param index subscript
- * @return A JSONObject value.
+ * @return A JSONObject value.
* @throws JSONException If there is no value for the index or if the
- * value is not a JSONObject
+ * value is not a JSONObject
*/
public JSONObject getJSONObject(int index) throws JSONException {
Object o = get(index);
@@ -275,9 +280,9 @@
* Get the long value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
- * @return The value.
- * @throws JSONException If the key is not found or if the value cannot
- * be converted to a number.
+ * @return The value.
+ * @throws JSONException If the key is not found or if the value cannot
+ * be converted to a number.
*/
public long getLong(int index) throws JSONException {
Object o = get(index);
@@ -287,8 +292,9 @@
/**
* Get the string associated with an index.
+ *
* @param index The index must be between 0 and length() - 1.
- * @return A string value.
+ * @return A string value.
* @throws JSONException If there is no value for the index.
*/
public String getString(int index) throws JSONException {
@@ -297,6 +303,7 @@
/**
* Determine if the value is null.
+ *
* @param index The index must be between 0 and length() - 1.
* @return true if the value at the index is null, or if there is no value.
*/
@@ -308,6 +315,7 @@
* Make a string from the contents of this JSONArray. The
* <code>separator</code> string is inserted between each element.
* Warning: This method assumes that the data structure is acyclical.
+ *
* @param separator A string that will be inserted between the elements.
* @return a string.
* @throws JSONException If the array contains an invalid number.
@@ -338,9 +346,10 @@
/**
* Get the optional object value associated with an index.
+ *
* @param index The index must be between 0 and length() - 1.
- * @return An object value, or null if there is no
- * object at that index.
+ * @return An object value, or null if there is no
+ * object at that index.
*/
public Object opt(int index) {
return ((index < 0) || (index >= length())) ? null :
this.myArrayList.get(index);
@@ -352,7 +361,7 @@
* or if the value is not Boolean.TRUE or the String "true".
*
* @param index The index must be between 0 and length() - 1.
- * @return The truth.
+ * @return The truth.
*/
public boolean optBoolean(int index) {
return optBoolean(index, false);
@@ -363,9 +372,9 @@
* It returns the defaultValue if there is no value at that index or if
* it is not a Boolean or the String "true" or "false" (case
insensitive).
*
- * @param index The index must be between 0 and length() - 1.
- * @param defaultValue A boolean default.
- * @return The truth.
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue A boolean default.
+ * @return The truth.
*/
public boolean optBoolean(int index, boolean defaultValue) {
try {
@@ -381,7 +390,7 @@
* or if the value is not a number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
- * @return The value.
+ * @return The value.
*/
public double optDouble(int index) {
return optDouble(index, Double.NaN);
@@ -392,9 +401,9 @@
* The defaultValue is returned if there is no value for the index,
* or if the value is not a number and cannot be converted to a number.
*
- * @param index subscript
- * @param defaultValue The default value.
- * @return The value.
+ * @param index subscript
+ * @param defaultValue The default value.
+ * @return The value.
*/
public double optDouble(int index, double defaultValue) {
try {
@@ -410,7 +419,7 @@
* or if the value is not a number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
- * @return The value.
+ * @return The value.
*/
public int optInt(int index) {
return optInt(index, 0);
@@ -420,9 +429,10 @@
* Get the optional int value associated with an index.
* The defaultValue is returned if there is no value for the index,
* or if the value is not a number and cannot be converted to a number.
- * @param index The index must be between 0 and length() - 1.
- * @param defaultValue The default value.
- * @return The value.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue The default value.
+ * @return The value.
*/
public int optInt(int index, int defaultValue) {
try {
@@ -434,9 +444,10 @@
/**
* Get the optional JSONArray associated with an index.
+ *
* @param index subscript
- * @return A JSONArray value, or null if the index has no value,
- * or if the value is not a JSONArray.
+ * @return A JSONArray value, or null if the index has no value,
+ * or if the value is not a JSONArray.
*/
public JSONArray optJSONArray(int index) {
Object o = opt(index);
@@ -450,7 +461,7 @@
* no value, or if the value is not a JSONObject.
*
* @param index The index must be between 0 and length() - 1.
- * @return A JSONObject value.
+ * @return A JSONObject value.
*/
public JSONObject optJSONObject(int index) {
Object o = opt(index);
@@ -464,7 +475,7 @@
* or if the value is not a number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
- * @return The value.
+ * @return The value.
*/
public long optLong(int index) {
return optLong(index, 0);
@@ -474,9 +485,10 @@
* Get the optional long value associated with an index.
* The defaultValue is returned if there is no value for the index,
* or if the value is not a number and cannot be converted to a number.
- * @param index The index must be between 0 and length() - 1.
- * @param defaultValue The default value.
- * @return The value.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue The default value.
+ * @return The value.
*/
public long optLong(int index, long defaultValue) {
try {
@@ -492,7 +504,7 @@
* is not a string and is not null, then it is coverted to a string.
*
* @param index The index must be between 0 and length() - 1.
- * @return A String value.
+ * @return A String value.
*/
public String optString(int index) {
return optString(index, "");
@@ -502,9 +514,9 @@
* Get the optional string associated with an index.
* The defaultValue is returned if the key is not found.
*
- * @param index The index must be between 0 and length() - 1.
- * @param defaultValue The default value.
- * @return A String value.
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue The default value.
+ * @return A String value.
*/
public String optString(int index, String defaultValue) {
Object o = opt(index);
@@ -527,8 +539,9 @@
/**
* Put a value in the JSONArray, where the value will be a
* JSONArray which is produced from a Collection.
+ *
* @param value A Collection value.
- * @return this.
+ * @return this.
*/
public JSONArray put(Collection value) {
put(new JSONArray(value));
@@ -540,8 +553,8 @@
* Append a double value. This increases the array's length by one.
*
* @param value A double value.
+ * @return this.
* @throws JSONException if the value is not finite.
- * @return this.
*/
public JSONArray put(double value) throws JSONException {
Double d = new Double(value);
@@ -579,8 +592,9 @@
/**
* Put a value in the JSONArray, where the value will be a
* JSONObject which is produced from a Map.
+ *
* @param value A Map value.
- * @return this.
+ * @return this.
*/
public JSONArray put(Map value) {
put(new JSONObject(value));
@@ -590,9 +604,10 @@
/**
* Append an object value. This increases the array's length by one.
+ *
* @param value An object value. The value should be a
- * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
- * JSONObject.NULL object.
+ * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or
the
+ * JSONObject.NULL object.
* @return this.
*/
public JSONArray put(Object value) {
@@ -605,6 +620,7 @@
* Put or replace a boolean value in the JSONArray. If the index is greater
* than the length of the JSONArray, then null elements will be added as
* necessary to pad it out.
+ *
* @param index The subscript.
* @param value A boolean value.
* @return this.
@@ -619,11 +635,12 @@
/**
* Put a value in the JSONArray, where the value will be a
* JSONArray which is produced from a Collection.
+ *
* @param index The subscript.
* @param value A Collection value.
- * @return this.
+ * @return this.
* @throws JSONException If the index is negative or if the value is
- * not finite.
+ * not finite.
*/
public JSONArray put(int index, Collection value) throws JSONException {
put(index, new JSONArray(value));
@@ -633,13 +650,14 @@
/**
* Put or replace a double value. If the index is greater than the length of
- * the JSONArray, then null elements will be added as necessary to pad
- * it out.
+ * the JSONArray, then null elements will be added as necessary to pad
+ * it out.
+ *
* @param index The subscript.
* @param value A double value.
* @return this.
* @throws JSONException If the index is negative or if the value is
- * not finite.
+ * not finite.
*/
public JSONArray put(int index, double value) throws JSONException {
put(index, new Double(value));
@@ -649,8 +667,9 @@
/**
* Put or replace an int value. If the index is greater than the length of
- * the JSONArray, then null elements will be added as necessary to pad
- * it out.
+ * the JSONArray, then null elements will be added as necessary to pad
+ * it out.
+ *
* @param index The subscript.
* @param value An int value.
* @return this.
@@ -664,8 +683,9 @@
/**
* Put or replace a long value. If the index is greater than the length of
- * the JSONArray, then null elements will be added as necessary to pad
- * it out.
+ * the JSONArray, then null elements will be added as necessary to pad
+ * it out.
+ *
* @param index The subscript.
* @param value A long value.
* @return this.
@@ -680,11 +700,12 @@
/**
* Put a value in the JSONArray, where the value will be a
* JSONObject which is produced from a Map.
+ *
* @param index The subscript.
* @param value The Map value.
- * @return this.
+ * @return this.
* @throws JSONException If the index is negative or if the the value is
- * an invalid number.
+ * an invalid number.
*/
public JSONArray put(int index, Map value) throws JSONException {
put(index, new JSONObject(value));
@@ -694,15 +715,16 @@
/**
* Put or replace an object value in the JSONArray. If the index is greater
- * than the length of the JSONArray, then null elements will be added as
- * necessary to pad it out.
+ * than the length of the JSONArray, then null elements will be added as
+ * necessary to pad it out.
+ *
* @param index The subscript.
* @param value The value to put into the array. The value should be a
- * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
- * JSONObject.NULL object.
+ * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or
the
+ * JSONObject.NULL object.
* @return this.
* @throws JSONException If the index is negative or if the the value is
- * an invalid number.
+ * an invalid number.
*/
public JSONArray put(int index, Object value) throws JSONException {
JSONObject.testValidity(value);
@@ -727,10 +749,11 @@
/**
* Produce a JSONObject by combining a JSONArray of names with the values
* of this JSONArray.
+ *
* @param names A JSONArray containing a list of key strings. These will be
- * paired with the values.
+ * paired with the values.
* @return A JSONObject, or null if there are no names or if this JSONArray
- * has no values.
+ * has no values.
* @throws JSONException If any of the names are null.
*/
public JSONObject toJSONObject(JSONArray names) throws JSONException {
@@ -752,11 +775,11 @@
* unnecessary whitespace is added. If it is not possible to produce a
* syntactically correct JSON text then null will be returned instead. This
* could occur if the array contains an invalid number.
- * <p>
+ * <p/>
* Warning: This method assumes that the data structure is acyclical.
*
* @return a printable, displayable, transmittable
- * representation of the array.
+ * representation of the array.
*/
public String toString() {
try {
@@ -769,12 +792,13 @@
/**
* Make a prettyprinted JSON text of this JSONArray.
* Warning: This method assumes that the data structure is acyclical.
+ *
* @param indentFactor The number of spaces to add to each level of
- * indentation.
+ * indentation.
* @return a printable, displayable, transmittable
- * representation of the object, beginning
- * with <code>[</code> <small>(left
bracket)</small> and ending
- * with <code>]</code> <small>(right
bracket)</small>.
+ * representation of the object, beginning
+ * with <code>[</code> <small>(left
bracket)</small> and ending
+ * with <code>]</code> <small>(right
bracket)</small>.
* @throws JSONException
*/
public String toString(int indentFactor) throws JSONException {
@@ -784,11 +808,12 @@
/**
* Make a prettyprinted JSON text of this JSONArray.
* Warning: This method assumes that the data structure is acyclical.
+ *
* @param indentFactor The number of spaces to add to each level of
- * indentation.
- * @param indent The indention of the top level.
+ * indentation.
+ * @param indent The indention of the top level.
* @return a printable, displayable, transmittable
- * representation of the array.
+ * representation of the array.
* @throws JSONException
*/
String toString(int indentFactor, int indent) throws JSONException {
@@ -835,7 +860,7 @@
/**
* Write the contents of the JSONArray as JSON text to a writer.
* For compactness, no whitespace is added.
- * <p>
+ * <p/>
* Warning: This method assumes that the data structure is acyclical.
*
* @return The writer.
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONCollection.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONCollection.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONCollection.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,19 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.json;
import java.io.Serializable;
-
import java.util.AbstractCollection;
import java.util.Iterator;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 15.12.2006
- *
+ * created 15.12.2006
*/
public class JSONCollection extends AbstractCollection implements Serializable {
@@ -59,9 +55,11 @@
public Iterator iterator() {
return new Iterator() {
int index = 0;
+
public boolean hasNext() {
return index < array.length();
}
+
public Object next() {
try {
return JSONAccessor.unwrapValue(array.get(index++));
@@ -73,6 +71,7 @@
throw new RuntimeException();
}
}
+
public void remove() {
throw new UnsupportedOperationException();
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONException.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONException.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONException.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,12 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.json;
/**
* The JSONException is thrown by the
JSON.org classes then things are amiss.
+ *
* @author
JSON.org
* @version 2
*/
@@ -42,6 +41,7 @@
/**
* Constructs a JSONException with an explanatory message.
+ *
* @param message Detail about the reason for the exception.
*/
public JSONException(String message) {
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONMap.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONMap.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONMap.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,18 +19,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.json;
import java.io.Serializable;
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.Set;
-import java.util.*;
-
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 15.12.2006
- *
+ * created 15.12.2006
*/
public class JSONMap extends AbstractMap implements Serializable {
private static final long serialVersionUID = 2898468948832273123L;
@@ -110,9 +109,11 @@
return new Entry() {
private String key = currentName;
+
public Object getKey() {
return key;
}
+
public Object getValue() {
try {
return JSONAccessor.getValue(jsonObject, this.key);
@@ -120,6 +121,7 @@
throw new RuntimeException(e.getMessage(), e);
}
}
+
public Object setValue(Object value) {
throw new UnsupportedOperationException();
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONObject.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONObject.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONObject.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -23,13 +23,12 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
+
import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.io.Writer;
-
import java.lang.reflect.Field;
-
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@@ -52,39 +51,40 @@
* exception if one cannot be found. An <code>opt</code> method returns a
* default value instead of throwing an exception, and so is useful for
* obtaining optional values.
- * <p>
+ * <p/>
* The generic <code>get()</code> and <code>opt()</code> methods
return an
* object, which you can cast or query for type. There are also typed
* <code>get</code> and <code>opt</code> methods that do type
checking and type
* coersion for you.
- * <p>
+ * <p/>
* The <code>put</code> methods adds values to an object. For example,
<pre>
* myString = new JSONObject().put("JSON", "Hello,
World!").toString();</pre>
* produces the string <code>{"JSON": "Hello,
World"}</code>.
- * <p>
+ * <p/>
* The texts produced by the <code>toString</code> methods strictly conform
to
* the JSON sysntax rules.
* The constructors are more forgiving in the texts they will accept:
* <ul>
* <li>An extra
<code>,</code> <small>(comma)</small> may appear just
- * before the closing brace.</li>
+ * before the closing brace.</li>
* <li>Strings may be quoted with
<code>'</code> <small>(single
- * quote)</small>.</li>
+ * quote)</small>.</li>
* <li>Strings do not need to be quoted at all if they do not begin with a quote
- * or single quote, and if they do not contain leading or trailing spaces,
- * and if they do not contain any of these characters:
- * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like
numbers
- * and if they are not the reserved words <code>true</code>,
- * <code>false</code>, or <code>null</code>.</li>
+ * or single quote, and if they do not contain leading or trailing spaces,
+ * and if they do not contain any of these characters:
+ * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers
+ * and if they are not the reserved words <code>true</code>,
+ * <code>false</code>, or <code>null</code>.</li>
* <li>Keys can be followed by <code>=</code> or
<code>=></code> as well as
- * by <code>:</code>.</li>
+ * by <code>:</code>.</li>
* <li>Values can be followed by <code>;</code>
<small>(semicolon)</small> as
- * well as by <code>,</code>
<small>(comma)</small>.</li>
+ * well as by <code>,</code> <small>(comma)</small>.</li>
* <li>Numbers may have the <code>0-</code>
<small>(octal)</small> or
- * <code>0x-</code> <small>(hex)</small> prefix.</li>
+ * <code>0x-</code> <small>(hex)</small> prefix.</li>
* <li>Comments written in the slashshlash, slashstar, and hash conventions
- * will be ignored.</li>
+ * will be ignored.</li>
* </ul>
+ *
* @author
JSON.org
* @version 2
*/
@@ -117,6 +117,7 @@
/**
* Construct a JSONObject from a JSONTokener.
+ *
* @param x A JSONTokener object containing the source string.
* @throws JSONException If there is a syntax error in the source string.
*/
@@ -134,13 +135,13 @@
c = x.nextClean();
switch (c) {
- case 0 :
+ case 0:
throw x.syntaxError("A JSONObject text must end with
'}'");
- case '}' :
+ case '}':
return;
- default :
+ default:
x.back();
key = x.nextValue().toString();
}
@@ -164,8 +165,8 @@
* Pairs are separated by ','. We will also tolerate ';'.
*/
switch (x.nextClean()) {
- case ';' :
- case ',' :
+ case ';':
+ case ',':
if (x.nextClean() == '}') {
return;
}
@@ -174,10 +175,10 @@
break;
- case '}' :
+ case '}':
return;
- default :
+ default:
throw x.syntaxError("Expected a ',' or
'}'");
}
}
@@ -185,8 +186,9 @@
/**
* Construct a JSONObject from a Map.
+ *
* @param map A map object that can be used to initialize the contents of
- * the JSONObject.
+ * the JSONObject.
*/
public JSONObject(Map map) {
this.myHashMap = (map == null) ? new HashMap() : new HashMap(map);
@@ -195,10 +197,11 @@
/**
* Construct a JSONObject from a string.
* This is the most commonly used JSONObject constructor.
- * @param string A string beginning
- * with <code>{</code> <small>(left brace)</small>
and ending
- * with <code>}</code> <small>(right
brace)</small>.
- * @exception JSONException If there is a syntax error in the source string.
+ *
+ * @param string A string beginning
+ * with <code>{</code> <small>(left
brace)</small> and ending
+ * with <code>}</code> <small>(right
brace)</small>.
+ * @throws JSONException If there is a syntax error in the source string.
*/
public JSONObject(String string) throws JSONException {
this(new JSONTokener(string));
@@ -208,9 +211,10 @@
* Construct a JSONObject from a subset of another JSONObject.
* An array of strings is used to identify the keys that should be copied.
* Missing keys are ignored.
+ *
* @param jo A JSONObject.
* @param sa An array of strings.
- * @exception JSONException If a value is a non-finite number.
+ * @throws JSONException If a value is a non-finite number.
*/
public JSONObject(JSONObject jo, String[] sa) throws JSONException {
this();
@@ -226,10 +230,11 @@
* from the names array, and the values will be the field values associated
* with those keys in the object. If a key is not found or not visible,
* then it will not be copied into the new JSONObject.
+ *
* @param object An object that has fields that should be used to make a
- * JSONObject.
- * @param names An array of strings, the names of the fields to be used
- * from the object.
+ * JSONObject.
+ * @param names An array of strings, the names of the fields to be used
+ * from the object.
*/
public JSONObject(Object object, String[] names) {
this();
@@ -256,11 +261,12 @@
* JSONArray is stored under the key to hold all of the accumulated values.
* If there is already a JSONArray, then the new value is appended to it.
* In contrast, the put method replaces the previous value.
+ *
* @param key A key string.
* @param value An object to be accumulated under the key.
* @return this.
* @throws JSONException If the value is an invalid number
- * or if the key is null.
+ * or if the key is null.
*/
public JSONObject accumulate(String key, Object value) throws JSONException {
testValidity(value);
@@ -283,11 +289,12 @@
* JSONObject, then the key is put in the JSONObject with its value being a
* JSONArray containing the value parameter. If the key was already
* associated with a JSONArray, then the value parameter is appended to it.
+ *
* @param key A key string.
* @param value An object to be accumulated under the key.
* @return this.
* @throws JSONException If the key is null or if the current value
- * associated with the key is not a JSONArray.
+ * associated with the key is not a JSONArray.
*/
public JSONObject append(String key, Object value) throws JSONException {
testValidity(value);
@@ -308,7 +315,8 @@
/**
* Produce a string from a double. The string "null" will be returned if
* the number is not finite.
- * @param d A double.
+ *
+ * @param d A double.
* @return A String.
*/
public static String doubleToString(double d) {
@@ -335,9 +343,9 @@
/**
* Get the value object associated with a key.
*
- * @param key A key string.
- * @return The object associated with the key.
- * @throws JSONException if the key is not found.
+ * @param key A key string.
+ * @return The object associated with the key.
+ * @throws JSONException if the key is not found.
*/
public Object get(String key) throws JSONException {
Object o = opt(key);
@@ -352,10 +360,9 @@
/**
* Get the boolean value associated with a key.
*
- * @param key A key string.
- * @return The truth.
- * @throws JSONException
- * if the value is not a Boolean or the String "true" or
"false".
+ * @param key A key string.
+ * @return The truth.
+ * @throws JSONException if the value is not a Boolean or the String "true"
or "false".
*/
public boolean getBoolean(String key) throws JSONException {
Object o = get(key);
@@ -371,10 +378,11 @@
/**
* Get the double value associated with a key.
- * @param key A key string.
- * @return The numeric value.
+ *
+ * @param key A key string.
+ * @return The numeric value.
* @throws JSONException if the key is not found or
- * if the value is not a Number object and cannot be converted to a number.
+ * if the value is not a Number object and cannot be converted
to a number.
*/
public double getDouble(String key) throws JSONException {
Object o = get(key);
@@ -390,10 +398,10 @@
* Get the int value associated with a key. If the number value is too
* large for an int, it will be clipped.
*
- * @param key A key string.
- * @return The integer value.
- * @throws JSONException if the key is not found or if the value cannot
- * be converted to an integer.
+ * @param key A key string.
+ * @return The integer value.
+ * @throws JSONException if the key is not found or if the value cannot
+ * be converted to an integer.
*/
public int getInt(String key) throws JSONException {
Object o = get(key);
@@ -404,10 +412,10 @@
/**
* Get the JSONArray value associated with a key.
*
- * @param key A key string.
- * @return A JSONArray which is the value.
- * @throws JSONException if the key is not found or
- * if the value is not a JSONArray.
+ * @param key A key string.
+ * @return A JSONArray which is the value.
+ * @throws JSONException if the key is not found or
+ * if the value is not a JSONArray.
*/
public JSONArray getJSONArray(String key) throws JSONException {
Object o = get(key);
@@ -422,10 +430,10 @@
/**
* Get the JSONObject value associated with a key.
*
- * @param key A key string.
- * @return A JSONObject which is the value.
- * @throws JSONException if the key is not found or
- * if the value is not a JSONObject.
+ * @param key A key string.
+ * @return A JSONObject which is the value.
+ * @throws JSONException if the key is not found or
+ * if the value is not a JSONObject.
*/
public JSONObject getJSONObject(String key) throws JSONException {
Object o = get(key);
@@ -441,10 +449,10 @@
* Get the long value associated with a key. If the number value is too
* long for a long, it will be clipped.
*
- * @param key A key string.
- * @return The long value.
- * @throws JSONException if the key is not found or if the value cannot
- * be converted to a long.
+ * @param key A key string.
+ * @return The long value.
+ * @throws JSONException if the key is not found or if the value cannot
+ * be converted to a long.
*/
public long getLong(String key) throws JSONException {
Object o = get(key);
@@ -455,9 +463,9 @@
/**
* Get the string associated with a key.
*
- * @param key A key string.
- * @return A string which is the value.
- * @throws JSONException if the key is not found.
+ * @param key A key string.
+ * @return A string which is the value.
+ * @throws JSONException if the key is not found.
*/
public String getString(String key) throws JSONException {
return get(key).toString();
@@ -465,8 +473,9 @@
/**
* Determine if the JSONObject contains a specific key.
- * @param key A key string.
- * @return true if the key exists in the JSONObject.
+ *
+ * @param key A key string.
+ * @return true if the key exists in the JSONObject.
*/
public boolean has(String key) {
return this.myHashMap.containsKey(key);
@@ -474,10 +483,11 @@
/**
* Determine if the value associated with the key is null or if there is
- * no value.
- * @param key A key string.
- * @return true if there is no value associated with the key or if
- * the value is the JSONObject.NULL object.
+ * no value.
+ *
+ * @param key A key string.
+ * @return true if there is no value associated with the key or if
+ * the value is the JSONObject.NULL object.
*/
public boolean isNull(String key) {
return JSONObject.NULL.equals(opt(key));
@@ -504,8 +514,9 @@
/**
* Produce a JSONArray containing the names of the elements of this
* JSONObject.
+ *
* @return A JSONArray containing the key strings, or null if the JSONObject
- * is empty.
+ * is empty.
*/
public JSONArray names() {
JSONArray ja = new JSONArray();
@@ -520,7 +531,8 @@
/**
* Produce a string from a Number.
- * @param n A Number
+ *
+ * @param n A Number
* @return A String.
* @throws JSONException If n is a non-finite number.
*/
@@ -549,8 +561,9 @@
/**
* Get an optional value associated with a key.
- * @param key A key string.
- * @return An object which is the value, or null if there is no value.
+ *
+ * @param key A key string.
+ * @return An object which is the value, or null if there is no value.
*/
public Object opt(String key) {
return (key == null) ? null : this.myHashMap.get(key);
@@ -561,8 +574,8 @@
* It returns false if there is no such key, or if the value is not
* Boolean.TRUE or the String "true".
*
- * @param key A key string.
- * @return The truth.
+ * @param key A key string.
+ * @return The truth.
*/
public boolean optBoolean(String key) {
return optBoolean(key, false);
@@ -573,9 +586,9 @@
* It returns the defaultValue if there is no such key, or if it is not
* a Boolean or the String "true" or "false" (case insensitive).
*
- * @param key A key string.
- * @param defaultValue The default.
- * @return The truth.
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return The truth.
*/
public boolean optBoolean(String key, boolean defaultValue) {
try {
@@ -588,9 +601,10 @@
/**
* Put a key/value pair in the JSONObject, where the value will be a
* JSONArray which is produced from a Collection.
+ *
* @param key A key string.
* @param value A Collection value.
- * @return this.
+ * @return this.
* @throws JSONException
*/
public JSONObject put(String key, Collection value) throws JSONException {
@@ -605,8 +619,8 @@
* If the value is a string, an attempt will be made to evaluate it as
* a number.
*
- * @param key A string which is the key.
- * @return An object which is the value.
+ * @param key A string which is the key.
+ * @return An object which is the value.
*/
public double optDouble(String key) {
return optDouble(key, Double.NaN);
@@ -618,9 +632,9 @@
* If the value is a string, an attempt will be made to evaluate it as
* a number.
*
- * @param key A key string.
- * @param defaultValue The default.
- * @return An object which is the value.
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return An object which is the value.
*/
public double optDouble(String key, double defaultValue) {
try {
@@ -638,8 +652,8 @@
* If the value is a string, an attempt will be made to evaluate it as
* a number.
*
- * @param key A key string.
- * @return An object which is the value.
+ * @param key A key string.
+ * @return An object which is the value.
*/
public int optInt(String key) {
return optInt(key, 0);
@@ -651,9 +665,9 @@
* If the value is a string, an attempt will be made to evaluate it as
* a number.
*
- * @param key A key string.
- * @param defaultValue The default.
- * @return An object which is the value.
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return An object which is the value.
*/
public int optInt(String key, int defaultValue) {
try {
@@ -668,8 +682,8 @@
* It returns null if there is no such key, or if its value is not a
* JSONArray.
*
- * @param key A key string.
- * @return A JSONArray which is the value.
+ * @param key A key string.
+ * @return A JSONArray which is the value.
*/
public JSONArray optJSONArray(String key) {
Object o = opt(key);
@@ -682,8 +696,8 @@
* It returns null if there is no such key, or if its value is not a
* JSONObject.
*
- * @param key A key string.
- * @return A JSONObject which is the value.
+ * @param key A key string.
+ * @return A JSONObject which is the value.
*/
public JSONObject optJSONObject(String key) {
Object o = opt(key);
@@ -697,8 +711,8 @@
* If the value is a string, an attempt will be made to evaluate it as
* a number.
*
- * @param key A key string.
- * @return An object which is the value.
+ * @param key A key string.
+ * @return An object which is the value.
*/
public long optLong(String key) {
return optLong(key, 0);
@@ -710,9 +724,9 @@
* If the value is a string, an attempt will be made to evaluate it as
* a number.
*
- * @param key A key string.
- * @param defaultValue The default.
- * @return An object which is the value.
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return An object which is the value.
*/
public long optLong(String key, long defaultValue) {
try {
@@ -727,8 +741,8 @@
* It returns an empty string if there is no such key. If the value is not
* a string and is not null, then it is coverted to a string.
*
- * @param key A key string.
- * @return A string which is the value.
+ * @param key A key string.
+ * @return A string which is the value.
*/
public String optString(String key) {
return optString(key, "");
@@ -738,9 +752,9 @@
* Get an optional string associated with a key.
* It returns the defaultValue if there is no such key.
*
- * @param key A key string.
- * @param defaultValue The default.
- * @return A string which is the value.
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return A string which is the value.
*/
public String optString(String key, String defaultValue) {
Object o = opt(key);
@@ -807,9 +821,10 @@
/**
* Put a key/value pair in the JSONObject, where the value will be a
* JSONObject which is produced from a Map.
+ *
* @param key A key string.
* @param value A Map value.
- * @return this.
+ * @return this.
* @throws JSONException
*/
public JSONObject put(String key, Map value) throws JSONException {
@@ -821,13 +836,14 @@
/**
* Put a key/value pair in the JSONObject. If the value is null,
* then the key will be removed from the JSONObject if it is present.
+ *
* @param key A key string.
* @param value An object which is the value. It should be of one of these
- * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
- * or the JSONObject.NULL object.
+ * types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
String,
+ * or the JSONObject.NULL object.
* @return this.
* @throws JSONException If the value is non-finite number
- * or if the key is null.
+ * or if the key is null.
*/
public JSONObject put(String key, Object value) throws JSONException {
if (key == null) {
@@ -847,10 +863,11 @@
/**
* Put a key/value pair in the JSONObject, but only if the
* key and the value are both non-null.
+ *
* @param key A key string.
* @param value An object which is the value. It should be of one of these
- * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
- * or the JSONObject.NULL object.
+ * types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
String,
+ * or the JSONObject.NULL object.
* @return this.
* @throws JSONException If the value is a non-finite number.
*/
@@ -867,8 +884,9 @@
* right places. A backslash will be inserted within </, allowing JSON
* text to be delivered in HTML. In JSON text, a string cannot contain a
* control character or an unescaped quote or backslash.
+ *
* @param string A String
- * @return A String correctly formatted for insertion in a JSON text.
+ * @return A String correctly formatted for insertion in a JSON text.
*/
public static String quote(String string) {
if ((string == null) || (string.length() == 0)) {
@@ -889,14 +907,14 @@
c = string.charAt(i);
switch (c) {
- case '\\' :
- case '"' :
+ case '\\':
+ case '"':
sb.append('\\');
sb.append(c);
break;
- case '/' :
+ case '/':
if (b == '<') {
sb.append('\\');
}
@@ -905,32 +923,32 @@
break;
- case '\b' :
+ case '\b':
sb.append("\\b");
break;
- case '\t' :
+ case '\t':
sb.append("\\t");
break;
- case '\n' :
+ case '\n':
sb.append("\\n");
break;
- case '\f' :
+ case '\f':
sb.append("\\f");
break;
- case '\r' :
+ case '\r':
sb.append("\\r");
break;
- default :
+ default:
if (c < ' ') {
t = "000" + Integer.toHexString(c);
sb.append("\\u" + t.substring(t.length() - 4));
@@ -947,9 +965,10 @@
/**
* Remove a name and its value, if present.
+ *
* @param key The name to be removed.
* @return The value that was associated with the name,
- * or null if there was no value.
+ * or null if there was no value.
*/
public Object remove(String key) {
return this.myHashMap.remove(key);
@@ -957,6 +976,7 @@
/**
* Throw an exception if the object is an NaN or infinite number.
+ *
* @param o The object to test.
* @throws JSONException If o is a non-finite number.
*/
@@ -977,8 +997,9 @@
/**
* Produce a JSONArray containing the values of the members of this
* JSONObject.
+ *
* @param names A JSONArray containing a list of key strings. This
- * determines the sequence of the values in the result.
+ * determines the sequence of the values in the result.
* @return A JSONArray of values.
* @throws JSONException If any of the values are non-finite numbers.
*/
@@ -1000,13 +1021,13 @@
* Make a JSON text of this JSONObject. For compactness, no whitespace
* is added. If this would not result in a syntactically correct JSON text,
* then null will be returned instead.
- * <p>
+ * <p/>
* Warning: This method assumes that the data structure is acyclical.
*
* @return a printable, displayable, portable, transmittable
- * representation of the object, beginning
- * with <code>{</code> <small>(left brace)</small>
and ending
- * with <code>}</code> <small>(right
brace)</small>.
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left
brace)</small> and ending
+ * with <code>}</code> <small>(right
brace)</small>.
*/
public String toString() {
try {
@@ -1035,14 +1056,15 @@
/**
* Make a prettyprinted JSON text of this JSONObject.
- * <p>
+ * <p/>
* Warning: This method assumes that the data structure is acyclical.
+ *
* @param indentFactor The number of spaces to add to each level of
- * indentation.
+ * indentation.
* @return a printable, displayable, portable, transmittable
- * representation of the object, beginning
- * with <code>{</code> <small>(left brace)</small>
and ending
- * with <code>}</code> <small>(right
brace)</small>.
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left
brace)</small> and ending
+ * with <code>}</code> <small>(right
brace)</small>.
* @throws JSONException If the object contains an invalid number.
*/
public String toString(int indentFactor) throws JSONException {
@@ -1051,15 +1073,16 @@
/**
* Make a prettyprinted JSON text of this JSONObject.
- * <p>
+ * <p/>
* Warning: This method assumes that the data structure is acyclical.
+ *
* @param indentFactor The number of spaces to add to each level of
- * indentation.
- * @param indent The indentation of the top level.
+ * indentation.
+ * @param indent The indentation of the top level.
* @return a printable, displayable, transmittable
- * representation of the object, beginning
- * with <code>{</code> <small>(left brace)</small>
and ending
- * with <code>}</code> <small>(right
brace)</small>.
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left
brace)</small> and ending
+ * with <code>}</code> <small>(right
brace)</small>.
* @throws JSONException If the object contains an invalid number.
*/
String toString(int indentFactor, int indent) throws JSONException {
@@ -1120,13 +1143,14 @@
* conforming text. If the object does not contain a toJSONString
* method (which is the most common case), then a text will be
* produced by the rules.
- * <p>
+ * <p/>
* Warning: This method assumes that the data structure is acyclical.
+ *
* @param value The value to be serialized.
* @return a printable, displayable, transmittable
- * representation of the object, beginning
- * with <code>{</code> <small>(left brace)</small>
and ending
- * with <code>}</code> <small>(right
brace)</small>.
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left
brace)</small> and ending
+ * with <code>}</code> <small>(right
brace)</small>.
* @throws JSONException If the value is or contains an invalid number.
*/
static String valueToString(Object value) throws JSONException {
@@ -1163,16 +1187,17 @@
/**
* Make a prettyprinted JSON text of an object value.
- * <p>
+ * <p/>
* Warning: This method assumes that the data structure is acyclical.
- * @param value The value to be serialized.
+ *
+ * @param value The value to be serialized.
* @param indentFactor The number of spaces to add to each level of
- * indentation.
- * @param indent The indentation of the top level.
+ * indentation.
+ * @param indent The indentation of the top level.
* @return a printable, displayable, transmittable
- * representation of the object, beginning
- * with <code>{</code> <small>(left brace)</small>
and ending
- * with <code>}</code> <small>(right
brace)</small>.
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left
brace)</small> and ending
+ * with <code>}</code> <small>(right
brace)</small>.
* @throws JSONException If the object contains an invalid number.
*/
static String valueToString(Object value, int indentFactor, int indent) throws
JSONException {
@@ -1215,7 +1240,7 @@
/**
* Write the contents of the JSONObject as JSON text to a writer.
* For compactness, no whitespace is added.
- * <p>
+ * <p/>
* Warning: This method assumes that the data structure is acyclical.
*
* @return The writer.
@@ -1274,7 +1299,8 @@
/**
* There is only intended to be a single instance of the NULL object,
* so the clone method returns itself.
- * @return NULL.
+ *
+ * @return NULL.
*/
@Override
protected Object clone() {
@@ -1283,9 +1309,10 @@
/**
* A Null object is equal to the null value and to itself.
- * @param object An object to test for nullness.
+ *
+ * @param object An object to test for nullness.
* @return true if the object parameter is the JSONObject.NULL object
- * or null.
+ * or null.
*/
@Override
public boolean equals(Object object) {
@@ -1299,6 +1326,7 @@
/**
* Get the "null" string value.
+ *
* @return The string "null".
*/
@Override
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONString.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONString.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONString.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.json;
/**
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONStringer.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONStringer.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONStringer.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -23,6 +23,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
+
import java.io.StringWriter;
/**
@@ -30,7 +31,7 @@
* The texts produced strictly conform to JSON syntax rules. No whitespace is
* added, so the results are ready for transmission or storage. Each instance of
* JSONStringer can produce one JSON text.
- * <p>
+ * <p/>
* A JSONStringer instance provides a <code>value</code> method for
appending
* values to the
* text, and a <code>key</code>
@@ -46,12 +47,13 @@
* .endObject()
* .toString();</pre> which produces the string <pre>
* {"JSON":"Hello, World!"}</pre>
- * <p>
+ * <p/>
* The first method called must be <code>array</code> or
<code>object</code>.
* There are no methods for adding commas or colons. JSONStringer adds them for
* you. Objects and arrays can be nested up to 20 levels deep.
- * <p>
+ * <p/>
* This can sometimes be easier than using a JSONObject to build a string.
+ *
* @author
JSON.org
* @version 2
*/
@@ -70,6 +72,7 @@
* problem in the construction of the JSON text (such as the calls to
* <code>array</code> were not properly balanced with calls to
* <code>endArray</code>).
+ *
* @return The JSON text.
*/
public String toString() {
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONTokener.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONTokener.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONTokener.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -28,6 +28,7 @@
* A JSONTokener takes a source string and extracts characters and tokens from
* it. It is used by the JSONObject and JSONArray constructors to parse
* JSON source strings.
+ *
* @author
JSON.org
* @version 2
*/
@@ -46,7 +47,7 @@
/**
* Construct a JSONTokener from a string.
*
- * @param s A source string.
+ * @param s A source string.
*/
public JSONTokener(String s) {
this.myIndex = 0;
@@ -66,9 +67,10 @@
/**
* Get the hex value of a character (base16).
+ *
* @param c A character between '0' and '9' or between 'A'
and 'F' or
- * between 'a' and 'f'.
- * @return An int between 0 and 15, or -1 if c was not a hex digit.
+ * between 'a' and 'f'.
+ * @return An int between 0 and 15, or -1 if c was not a hex digit.
*/
public static int dehexchar(char c) {
if ((c >= '0') && (c <= '9')) {
@@ -89,6 +91,7 @@
/**
* Determine if the source string still contains characters that next()
* can consume.
+ *
* @return true if not yet at the end of the source.
*/
public boolean more() {
@@ -115,6 +118,7 @@
/**
* Consume the next character, and check that it matches a specified
* character.
+ *
* @param c The character to match.
* @return The character.
* @throws JSONException if the character does not match.
@@ -132,11 +136,10 @@
/**
* Get the next n characters.
*
- * @param n The number of characters to take.
- * @return A string of n characters.
- * @throws JSONException
- * Substring bounds error if there are not
- * n characters remaining in the source string.
+ * @param n The number of characters to take.
+ * @return A string of n characters.
+ * @throws JSONException Substring bounds error if there are not
+ * n characters remaining in the source string.
*/
public String next(int n) throws JSONException {
int i = this.myIndex;
@@ -154,8 +157,9 @@
/**
* Get the next char in the string, skipping whitespace
* and comments (slashslash, slashstar, and hash).
+ *
+ * @return A character, or 0 if there are no more characters.
* @throws JSONException
- * @return A character, or 0 if there are no more characters.
*/
public char nextClean() throws JSONException {
for (;;) {
@@ -163,14 +167,14 @@
if (c == '/') {
switch (next()) {
- case '/' :
+ case '/':
do {
c = next();
} while ((c != '\n') && (c != '\r')
&& (c != 0));
break;
- case '*' :
+ case '*':
for (;;) {
c = next();
@@ -189,7 +193,7 @@
break;
- default :
+ default:
back();
return '/';
@@ -209,10 +213,11 @@
* Backslash processing is done. The formal JSON format does not
* allow strings in single quotes, but an implementation is allowed to
* accept them.
+ *
* @param quote The quoting character, either
- * <code>"</code> <small>(double
quote)</small> or
- * <code>'</code> <small>(single
quote)</small>.
- * @return A String.
+ * <code>"</code> <small>(double
quote)</small> or
+ * <code>'</code> <small>(single
quote)</small>.
+ * @return A String.
* @throws JSONException Unterminated string.
*/
public String nextString(char quote) throws JSONException {
@@ -223,57 +228,57 @@
c = next();
switch (c) {
- case 0 :
- case '\n' :
- case '\r' :
+ case 0:
+ case '\n':
+ case '\r':
throw syntaxError("Unterminated string");
- case '\\' :
+ case '\\':
c = next();
switch (c) {
- case 'b' :
+ case 'b':
sb.append('\b');
break;
- case 't' :
+ case 't':
sb.append('\t');
break;
- case 'n' :
+ case 'n':
sb.append('\n');
break;
- case 'f' :
+ case 'f':
sb.append('\f');
break;
- case 'r' :
+ case 'r':
sb.append('\r');
break;
- case 'u' :
+ case 'u':
sb.append((char) Integer.parseInt(next(4), 16));
break;
- case 'x' :
+ case 'x':
sb.append((char) Integer.parseInt(next(2), 16));
break;
- default :
+ default:
sb.append(c);
}
break;
- default :
+ default:
if (c == quote) {
return sb.toString();
}
@@ -286,8 +291,9 @@
/**
* Get the text up but not including the specified character or the
* end of line, whichever comes first.
- * @param d A delimiter character.
- * @return A string.
+ *
+ * @param d A delimiter character.
+ * @return A string.
*/
public String nextTo(char d) {
StringBuffer sb = new StringBuffer();
@@ -310,6 +316,7 @@
/**
* Get the text up but not including one of the specified delimeter
* characters or the end of line, whichever comes first.
+ *
* @param delimiters A set of delimiter characters.
* @return A string, trimmed.
*/
@@ -335,25 +342,25 @@
/**
* Get the next value. The value can be a Boolean, Double, Integer,
* JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
- * @throws JSONException If syntax error.
*
* @return An object.
+ * @throws JSONException If syntax error.
*/
public Object nextValue() throws JSONException {
char c = nextClean();
String s;
switch (c) {
- case '"' :
- case '\'' :
+ case '"':
+ case '\'':
return nextString(c);
- case '{' :
+ case '{':
back();
return new JSONObject(this);
- case '[' :
+ case '[':
back();
return new JSONArray(this);
@@ -445,9 +452,10 @@
/**
* Skip characters until the next character is the requested character.
* If the requested character is not found, no characters are skipped.
+ *
* @param to A character to skip to.
* @return The requested character, or zero if the requested character
- * is not found.
+ * is not found.
*/
public char skipTo(char to) {
char c;
@@ -471,6 +479,7 @@
/**
* Skip characters until past the requested string.
* If it is not found, we are left at the end of the source.
+ *
* @param to A string to skip past.
*/
public void skipPast(String to) {
@@ -487,7 +496,7 @@
* Make a JSONException to signal a syntax error.
*
* @param message The error message.
- * @return A JSONException object, suitable for throwing
+ * @return A JSONException object, suitable for throwing
*/
public JSONException syntaxError(String message) {
return new JSONException(message + toString());
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONWriter.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONWriter.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/JSONWriter.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -32,7 +32,7 @@
* The texts produced strictly conform to JSON syntax rules. No whitespace is
* added, so the results are ready for transmission or storage. Each instance of
* JSONWriter can produce one JSON text.
- * <p>
+ * <p/>
* A JSONWriter instance provides a <code>value</code> method for appending
* values to the
* text, and a <code>key</code>
@@ -47,12 +47,13 @@
* .value("Hello, World!")
* .endObject();</pre> which writes <pre>
* {"JSON":"Hello, World!"}</pre>
- * <p>
+ * <p/>
* The first method called must be <code>array</code> or
<code>object</code>.
* There are no methods for adding commas or colons. JSONWriter adds them for
* you. Objects and arrays can be nested up to 20 levels deep.
- * <p>
+ * <p/>
* This can sometimes be easier than using a JSONObject to build a string.
+ *
* @author
JSON.org
* @version 2
*/
@@ -60,12 +61,6 @@
private static final int MAX_DEPTH = 20;
/**
- * The comma flag determines if a comma should be output before the next
- * value.
- */
- private boolean comma;
-
- /**
* The current mode. Values:
* 'a' (array),
* 'd' (done),
@@ -76,6 +71,17 @@
protected char mode;
/**
+ * The writer that will receive the output.
+ */
+ protected Writer writer;
+
+ /**
+ * The comma flag determines if a comma should be output before the next
+ * value.
+ */
+ private boolean comma;
+
+ /**
* The object/array stack.
*/
private char[] stack;
@@ -86,11 +92,6 @@
private int top;
/**
- * The writer that will receive the output.
- */
- protected Writer writer;
-
- /**
* Make a fresh JSONWriter. It can be used to build one JSON text.
*/
public JSONWriter(Writer w) {
@@ -103,6 +104,7 @@
/**
* Append a value.
+ *
* @param s A string value.
* @return this
* @throws JSONException If the value is out of sequence.
@@ -139,10 +141,11 @@
* Begin appending a new array. All values until the balancing
* <code>endArray</code> will be appended to this array. The
* <code>endArray</code> method must be called to mark the array's
end.
+ *
* @return this
* @throws JSONException If the nesting is too deep, or if the object is
- * started in the wrong place (for example as a key or after the end of the
- * outermost array or object).
+ * started in the wrong place (for example as a key or after
the end of the
+ * outermost array or object).
*/
public JSONWriter array() throws JSONException {
if ((this.mode == 'i') || (this.mode == 'o') || (this.mode ==
'a')) {
@@ -158,6 +161,7 @@
/**
* End something.
+ *
* @param m Mode
* @param c Closing character
* @return this
@@ -184,6 +188,7 @@
/**
* End an array. This method most be called to balance calls to
* <code>array</code>.
+ *
* @return this
* @throws JSONException If incorrectly nested.
*/
@@ -194,6 +199,7 @@
/**
* End an object. This method most be called to balance calls to
* <code>object</code>.
+ *
* @return this
* @throws JSONException If incorrectly nested.
*/
@@ -204,10 +210,11 @@
/**
* Append a key. The key will be associated with the next value. In an
* object, every value must be preceded by a key.
+ *
* @param s A key string.
* @return this
* @throws JSONException If the key is out of place. For example, keys
- * do not belong in arrays or if the key is null.
+ * do not belong in arrays or if the key is null.
*/
public JSONWriter key(String s) throws JSONException {
if (s == null) {
@@ -238,10 +245,11 @@
* Begin appending a new object. All keys and values until the balancing
* <code>endObject</code> will be appended to this object. The
* <code>endObject</code> method must be called to mark the object's
end.
+ *
* @return this
* @throws JSONException If the nesting is too deep, or if the object is
- * started in the wrong place (for example as a key or after the end of the
- * outermost array or object).
+ * started in the wrong place (for example as a key or after
the end of the
+ * outermost array or object).
*/
public JSONWriter object() throws JSONException {
if (this.mode == 'i') {
@@ -261,6 +269,7 @@
/**
* Pop an array or object scope.
+ *
* @param c The scope to close.
* @throws JSONException If nesting is wrong.
*/
@@ -275,6 +284,7 @@
/**
* Push an array or object scope.
+ *
* @param c The scope to open.
* @throws JSONException If nesting is too deep.
*/
@@ -291,6 +301,7 @@
/**
* Append either the value <code>true</code> or the value
* <code>false</code>.
+ *
* @param b A boolean.
* @return this
* @throws JSONException
@@ -301,6 +312,7 @@
/**
* Append a double value.
+ *
* @param d A double.
* @return this
* @throws JSONException If the number is not finite.
@@ -311,6 +323,7 @@
/**
* Append a long value.
+ *
* @param l A long.
* @return this
* @throws JSONException
@@ -321,9 +334,10 @@
/**
* Append an object value.
+ *
* @param o The object to append. It can be null, or a Boolean, Number,
- * String, JSONObject, or JSONArray, or an object with a toJSONString()
- * method.
+ * String, JSONObject, or JSONArray, or an object with a toJSONString()
+ * method.
* @return this
* @throws JSONException If the value is out of sequence.
*/
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/XML.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/XML.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/XML.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -23,44 +23,65 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
+
import java.util.Iterator;
/**
* This provides static methods to convert an XML text into a JSONObject,
* and to covert a JSONObject into an XML text.
+ *
* @author
JSON.org
* @version 2
*/
public final class XML {
- /** The Character '&'. */
+ /**
+ * The Character '&'.
+ */
public static final Character AMP = new Character('&');
- /** The Character '''. */
+ /**
+ * The Character '''.
+ */
public static final Character APOS = new Character('\'');
- /** The Character '!'. */
+ /**
+ * The Character '!'.
+ */
public static final Character BANG = new Character('!');
- /** The Character '='. */
+ /**
+ * The Character '='.
+ */
public static final Character EQ = new Character('=');
- /** The Character '>'. */
+ /**
+ * The Character '>'.
+ */
public static final Character GT = new Character('>');
- /** The Character '<'. */
+ /**
+ * The Character '<'.
+ */
public static final Character LT = new Character('<');
- /** The Character '?'. */
+ /**
+ * The Character '?'.
+ */
public static final Character QUEST = new Character('?');
- /** The Character '"'. */
+ /**
+ * The Character '"'.
+ */
public static final Character QUOT = new Character('"');
- /** The Character '/'. */
+ /**
+ * The Character '/'.
+ */
public static final Character SLASH = new Character('/');
- private XML() {}
+ private XML() {
+ }
/**
* Replace special characters with XML escapes:
@@ -70,6 +91,7 @@
* > <small>(greater than)</small> is replaced by &gt;
* " <small>(double quote)</small> is replaced by
&quot;
* </pre>
+ *
* @param string The string to be escaped.
* @return The escaped string.
*/
@@ -81,27 +103,27 @@
char c = string.charAt(i);
switch (c) {
- case '&' :
+ case '&':
sb.append("&");
break;
- case '<' :
+ case '<':
sb.append("<");
break;
- case '>' :
+ case '>':
sb.append(">");
break;
- case '"' :
+ case '"':
sb.append(""");
break;
- default :
+ default:
sb.append(c);
}
}
@@ -111,6 +133,7 @@
/**
* Scan the content following the named tag, attaching it to the context.
+ *
* @param x The XMLTokener containing the source string.
* @param context The JSONObject that will include the new material.
* @param name The tag name.
@@ -291,6 +314,7 @@
* Sequences of similar elements are represented as JSONArrays. Content
* text may be placed in a "content" member. Comments, prologs, DTDs, and
* <code><[ [ ]]></code> are ignored.
+ *
* @param string The source string.
* @return A JSONObject containing the structured data from the XML string.
* @throws JSONException
@@ -309,9 +333,10 @@
/**
* Convert a JSONObject into a well-formed, element-normal XML string.
+ *
* @param o A JSONObject.
- * @return A string.
- * @throws JSONException
+ * @return A string.
+ * @throws JSONException
*/
public static String toString(Object o) throws JSONException {
return toString(o, null);
@@ -319,7 +344,8 @@
/**
* Convert a JSONObject into a well-formed, element-normal XML string.
- * @param o A JSONObject.
+ *
+ * @param o A JSONObject.
* @param tagName The optional name of the enclosing tag.
* @return A string.
* @throws JSONException
@@ -419,8 +445,8 @@
s = (o == null) ? "null" : escape(o.toString());
return (tagName == null)
- ? "\"" + s + "\""
- : (s.length() == 0) ? "<" + tagName + "/>" :
"<" + tagName + ">" + s + "</" + tagName +
">";
+ ? "\"" + s + "\""
+ : (s.length() == 0) ? "<" + tagName + "/>" :
"<" + tagName + ">" + s + "</" + tagName +
">";
}
}
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/XMLTokener.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/json/XMLTokener.java 2009-12-04
20:46:42 UTC (rev 16071)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/json/XMLTokener.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -27,6 +27,7 @@
/**
* The XMLTokener extends the JSONTokener to provide additional methods
* for the parsing of XML texts.
+ *
* @author
JSON.org
* @version 2
*/
@@ -49,6 +50,7 @@
/**
* Construct an XMLTokener from a string.
+ *
* @param s A source string.
*/
public XMLTokener(String s) {
@@ -57,6 +59,7 @@
/**
* Get the text in the CDATA block.
+ *
* @return The string up to the <code>]]></code>.
* @throws JSONException If the <code>]]></code> is not found.
*/
@@ -88,8 +91,8 @@
* of tokens: the '<' character which begins a markup tag, and the
content
* text between markup tags.
*
- * @return A string, or a '<' Character, or null if there is no more
- * source text.
+ * @return A string, or a '<' Character, or null if there is no more
+ * source text.
* @throws JSONException
*/
public Object nextContent() throws JSONException {
@@ -129,9 +132,10 @@
/**
* Return the next entity. These entities are translated to Characters:
- * <code>& ' > <
"</code>.
+ * <code>& ' > < "</code>.
+ *
* @param a An ampersand character.
- * @return A Character or an entity String if the entity is not recognized.
+ * @return A Character or an entity String if the entity is not recognized.
* @throws JSONException If missing ';' in XML entity.
*/
public Object nextEntity(char a) throws JSONException {
@@ -158,11 +162,12 @@
/**
* Returns the next XML meta token. This is used for skipping over <!...>
* and <?...?> structures.
+ *
* @return Syntax characters (<code>< > / = ! ?</code>) are
returned as
- * Character, and strings and names are returned as Boolean. We don't care
- * what the values actually are.
+ * Character, and strings and names are returned as Boolean. We don't
care
+ * what the values actually are.
* @throws JSONException If a string is not properly closed or if the XML
- * is badly structured.
+ * is badly structured.
*/
public Object nextMeta() throws JSONException {
char c;
@@ -173,29 +178,29 @@
} while (Character.isWhitespace(c));
switch (c) {
- case 0 :
+ case 0:
throw syntaxError("Misshaped meta tag.");
- case '<' :
+ case '<':
return XML.LT;
- case '>' :
+ case '>':
return XML.GT;
- case '/' :
+ case '/':
return XML.SLASH;
- case '=' :
+ case '=':
return XML.EQ;
- case '!' :
+ case '!':
return XML.BANG;
- case '?' :
+ case '?':
return XML.QUEST;
- case '"' :
- case '\'' :
+ case '"':
+ case '\'':
q = c;
for (;;) {
@@ -209,7 +214,7 @@
return Boolean.TRUE;
}
}
- default :
+ default:
for (;;) {
c = next();
@@ -218,22 +223,22 @@
}
switch (c) {
- case 0 :
- case '<' :
- case '>' :
- case '/' :
- case '=' :
- case '!' :
- case '?' :
- case '"' :
- case '\'' :
+ case 0:
+ case '<':
+ case '>':
+ case '/':
+ case '=':
+ case '!':
+ case '?':
+ case '"':
+ case '\'':
back();
return Boolean.TRUE;
- default :
+ default:
- // TODO Refactoring
+ // TODO Refactoring
}
}
}
@@ -244,6 +249,7 @@
* brackets. It may be one of these characters: <code>/ > = ! ?</code>
or it
* may be a string wrapped in single quotes or double quotes, or it may be a
* name.
+ *
* @return a String or a Character.
* @throws JSONException If the XML is not well formed.
*/
@@ -257,30 +263,30 @@
} while (Character.isWhitespace(c));
switch (c) {
- case 0 :
+ case 0:
throw syntaxError("Misshaped element.");
- case '<' :
+ case '<':
throw syntaxError("Misplaced '<'.");
- case '>' :
+ case '>':
return XML.GT;
- case '/' :
+ case '/':
return XML.SLASH;
- case '=' :
+ case '=':
return XML.EQ;
- case '!' :
+ case '!':
return XML.BANG;
- case '?' :
+ case '?':
return XML.QUEST;
// Quoted string
- case '"' :
- case '\'' :
+ case '"':
+ case '\'':
q = c;
sb = new StringBuffer();
@@ -301,7 +307,7 @@
sb.append(c);
}
}
- default :
+ default:
// Name
sb = new StringBuffer();
@@ -315,26 +321,26 @@
}
switch (c) {
- case 0 :
- case '>' :
- case '/' :
- case '=' :
- case '!' :
- case '?' :
- case '[' :
- case ']' :
+ case 0:
+ case '>':
+ case '/':
+ case '=':
+ case '!':
+ case '?':
+ case '[':
+ case ']':
back();
return sb.toString();
- case '<' :
- case '"' :
- case '\'' :
+ case '<':
+ case '"':
+ case '\'':
throw syntaxError("Bad character in a name.");
- default :
+ default:
- // TODO Refactoring
+ // TODO Refactoring
}
}
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/json/package-info.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/json/package-info.java 2009-12-04
20:46:42 UTC (rev 16071)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/json/package-info.java 2009-12-04
20:49:13 UTC (rev 16072)
@@ -1,4 +1,3 @@
-
/**
* JSON handling classes. Contains <a
href="http://www.json.org">implementation</a> of JSON library together
with JSON-based basic container classes implementation
*/