CPD Results
The following document contains the results of PMD's CPD 4.2.5.
Duplications
File | Line |
---|---|
javax/faces/component/_DeltaList.java | 47 |
javax/faces/component/behavior/_DeltaList.java | 49 |
{ private List<T> _delegate; private boolean _initialStateMarked; public _DeltaList() { } public _DeltaList(List<T> delegate) { _delegate = delegate; } public void add(int index, T element) { clearInitialState(); _delegate.add(index, element); } public boolean add(T e) { clearInitialState(); return _delegate.add(e); } public boolean addAll(Collection<? extends T> c) { clearInitialState(); return _delegate.addAll(c); } public boolean addAll(int index, Collection<? extends T> c) { clearInitialState(); return _delegate.addAll(index, c); } public void clear() { clearInitialState(); _delegate.clear(); } public boolean contains(Object o) { return _delegate.contains(o); } public boolean containsAll(Collection<?> c) { return _delegate.containsAll(c); } public boolean equals(Object o) { return _delegate.equals(o); } public T get(int index) { return _delegate.get(index); } public int hashCode() { return _delegate.hashCode(); } public int indexOf(Object o) { return _delegate.indexOf(o); } public boolean isEmpty() { return _delegate.isEmpty(); } public Iterator<T> iterator() { return _delegate.iterator(); } public int lastIndexOf(Object o) { return _delegate.lastIndexOf(o); } public ListIterator<T> listIterator() { return _delegate.listIterator(); } public ListIterator<T> listIterator(int index) { return _delegate.listIterator(index); } public T remove(int index) { clearInitialState(); return _delegate.remove(index); } public boolean remove(Object o) { clearInitialState(); return _delegate.remove(o); } public boolean removeAll(Collection<?> c) { clearInitialState(); return _delegate.removeAll(c); } public boolean retainAll(Collection<?> c) { clearInitialState(); return _delegate.retainAll(c); } public T set(int index, T element) { clearInitialState(); return _delegate.set(index, element); } public int size() { return _delegate == null ? 0 : _delegate.size(); } public List<T> subList(int fromIndex, int toIndex) { return _delegate.subList(fromIndex, toIndex); } public Object[] toArray() { return _delegate.toArray(); } public <T> T[] toArray(T[] a) { return _delegate.toArray(a); } public boolean isTransient() { return false; } public void setTransient(boolean newTransientValue) { throw new UnsupportedOperationException(); } public void restoreState(FacesContext context, Object state) { if (state == null) { return; } if (initialStateMarked()) { //Restore delta Object[] lst = (Object[]) state; int j = 0; int i = 0; while (i < lst.length) { if (lst[i] instanceof _AttachedDeltaWrapper) { //Delta ((StateHolder)_delegate.get(j)).restoreState(context, ((_AttachedDeltaWrapper) lst[i]).getWrappedStateObject()); j++; } else if (lst[i] != null) { //Full _delegate.set(j, (T) UIComponentBase.restoreAttachedState(context, lst[i])); j++; } else { _delegate.remove(j); } i++; } if (i != j) { // StateHolder transient objects found, next time save and restore it fully //because the size of the list changes. clearInitialState(); } } else { //Restore delegate Object[] lst = (Object[]) state; _delegate = new ArrayList<T>(lst.length); for (int i = 0; i < lst.length; i++) { T value = (T) UIComponentBase.restoreAttachedState(context, lst[i]); if (value != null) { _delegate.add(value); } } } } public Object saveState(FacesContext context) { if (initialStateMarked()) { Object [] lst = new Object[_delegate.size()]; boolean nullDelta = true; for (int i = 0; i < _delegate.size(); i++) { Object value = _delegate.get(i); if (value instanceof PartialStateHolder) { //Delta PartialStateHolder holder = (PartialStateHolder) value; if (!holder.isTransient()) { Object attachedState = holder.saveState(context); if (attachedState != null) { nullDelta = false; } lst[i] = new _AttachedDeltaWrapper(value.getClass(), attachedState); } } else { //Full lst[i] = UIComponentBase.saveAttachedState(context, value); if (value instanceof StateHolder || value instanceof List) { nullDelta = false; } } } if (nullDelta) { return null; } return lst; } else { Object [] lst = new Object[_delegate.size()]; for (int i = 0; i < _delegate.size(); i++) { lst[i] = UIComponentBase.saveAttachedState(context, _delegate.get(i)); } return lst; } } public void clearInitialState() { //Reset delta setting to null if (_initialStateMarked) { _initialStateMarked = false; if (_delegate != null) { for (T value : _delegate) { if (value instanceof PartialStateHolder) { ((PartialStateHolder)value).clearInitialState(); } } } } } public boolean initialStateMarked() { return _initialStateMarked; } public void markInitialState() { _initialStateMarked = true; if (_delegate != null) { int size = _delegate.size(); for (int i = 0; i < size; i++) { T value = _delegate.get(i); if (value instanceof PartialStateHolder) { ((PartialStateHolder)value).markInitialState(); } } } } } |
File | Line |
---|---|
javax/faces/component/behavior/_AjaxBehaviorDeltaStateHelper.java | 181 |
javax/faces/component/behavior/_DeltaStateHelper.java | 287 |
} else { _deltas.put(key, value); returnValue = _fullState.put(key, value); } } else { /* if (value instanceof StateHolder) { _stateHolderKeys.add(key); } */ returnValue = _fullState.put(key, value); } return returnValue; } public Object put(Serializable key, String mapKey, Object value) { boolean returnSet = false; Object returnValue = null; if (_createDeltas()) { //Track delta case Map<String, Object> mapValues = (Map<String, Object>) _deltas .get(key); if (mapValues == null) { mapValues = new InternalMap<String, Object>(); _deltas.put(key, mapValues); } if (mapValues.containsKey(mapKey)) { returnValue = mapValues.put(mapKey, value); returnSet = true; } else { mapValues.put(mapKey, value); } } //Handle change on full map Map<String, Object> mapValues = (Map<String, Object>) _fullState .get(key); if (mapValues == null) { mapValues = new InternalMap<String, Object>(); _fullState.put(key, mapValues); } if (returnSet) { mapValues.put(mapKey, value); } else { returnValue = mapValues.put(mapKey, value); } return returnValue; } public Object remove(Serializable key) { Object returnValue = null; if (_createDeltas()) { if (_deltas.containsKey(key)) { // Keep track of the removed values using key/null pair on the delta map returnValue = _deltas.put(key, null); _fullState.remove(key); } else { // Keep track of the removed values using key/null pair on the delta map _deltas.put(key, null); returnValue = _fullState.remove(key); } } else { returnValue = _fullState.remove(key); } return returnValue; } public Object remove(Serializable key, Object valueOrKey) { // Comment by lu4242 : The spec javadoc says if it is a Collection // or Map deal with it. But the intention of this method is work // with add(?,?) and put(?,?,?), this ones return instances of // InternalMap and InternalList to prevent mixing, so to be // consistent we'll cast to those classes here. Object collectionOrMap = _fullState.get(key); Object returnValue = null; if (collectionOrMap instanceof InternalMap) { if (_createDeltas()) { returnValue = _removeValueOrKeyFromMap(_deltas, key, valueOrKey, true); _removeValueOrKeyFromMap(_fullState, key, valueOrKey, false); } else { returnValue = _removeValueOrKeyFromMap(_fullState, key, valueOrKey, false); } } else if (collectionOrMap instanceof InternalList) { if (_createDeltas()) { returnValue = _removeValueOrKeyFromCollectionDelta(_deltas, key, valueOrKey); _removeValueOrKeyFromCollection(_fullState, key, valueOrKey); } else { returnValue = _removeValueOrKeyFromCollection(_fullState, key, valueOrKey); } } return returnValue; } private static Object _removeValueOrKeyFromCollectionDelta( Map<Serializable, Object> stateMap, Serializable key, Object valueOrKey) { Object returnValue = null; Map<Object, Boolean> c = (Map<Object, Boolean>) stateMap.get(key); if (c != null) { if (c.containsKey(valueOrKey)) { returnValue = valueOrKey; } c.put(valueOrKey, Boolean.FALSE); } return returnValue; } private static Object _removeValueOrKeyFromCollection( Map<Serializable, Object> stateMap, Serializable key, Object valueOrKey) { Object returnValue = null; Collection c = (Collection) stateMap.get(key); if (c != null) { if (c.remove(valueOrKey)) { returnValue = valueOrKey; } if (c.isEmpty()) { stateMap.remove(key); } } return returnValue; } private static Object _removeValueOrKeyFromMap( Map<Serializable, Object> stateMap, Serializable key, Object valueOrKey, boolean delta) { if (valueOrKey == null) { return null; } Object returnValue = null; Map<String, Object> map = (Map<String, Object>) stateMap.get(key); if (map != null) { if (delta) { // Keep track of the removed values using key/null pair on the delta map returnValue = map.put((String) valueOrKey, null); } else { returnValue = map.remove(valueOrKey); } if (map.isEmpty()) { //stateMap.remove(key); stateMap.put(key, null); } } return returnValue; } public boolean isTransient() { return _transient; } /** * Serializing cod * the serialized data structure consists of key value pairs unless the value itself is an internal array * or a map in case of an internal array or map the value itself is another array with its initial value * myfaces.InternalArray, myfaces.internalMap * * the internal Array is then mapped to another array * * the internal Map again is then mapped to a map with key value pairs * * */ public Object saveState(FacesContext context) { Map serializableMap = (isInitialStateMarked()) ? _deltas : _fullState; if (serializableMap == null || serializableMap.size() == 0) { return null; } /* int stateHolderKeyCount = 0; if (isInitalStateMarked()) { for (Iterator<Serializable> it = _stateHolderKeys.iterator(); it.hasNext();) { Serializable key = it.next(); if (!_deltas.containsKey(key)) { stateHolderKeyCount++; } } }*/ Map.Entry<Serializable, Object> entry; //entry == key, value, key, value Object[] retArr = new Object[serializableMap.entrySet().size() * 2]; //Object[] retArr = new Object[serializableMap.entrySet().size() * 2 + stateHolderKeyCount]; Iterator<Map.Entry<Serializable, Object>> it = serializableMap .entrySet().iterator(); int cnt = 0; while (it.hasNext()) { entry = it.next(); retArr[cnt] = entry.getKey(); Object value = entry.getValue(); // The condition in which the call to saveAttachedState // is to handle List, StateHolder or non Serializable instances. // we check it here, to prevent unnecessary calls. if (value instanceof StateHolder || value instanceof List || !(value instanceof Serializable)) { Object savedValue = saveAttachedState(context, |
File | Line |
---|---|
javax/faces/component/_DeltaStateHelper.java | 266 |
javax/faces/component/behavior/_DeltaStateHelper.java | 263 |
return expression.getValue(FacesContext.getCurrentInstance() .getELContext()); } return defaultValue; } public Object get(Serializable key) { return _fullState.get(key); } public Object put(Serializable key, Object value) { Object returnValue = null; if (_createDeltas()) { if (_deltas.containsKey(key)) { returnValue = _deltas.put(key, value); _fullState.put(key, value); } else if (value == null && !_fullState.containsKey(key)) { returnValue = null; } else { _deltas.put(key, value); returnValue = _fullState.put(key, value); } } else { /* if (value instanceof StateHolder) { _stateHolderKeys.add(key); } */ returnValue = _fullState.put(key, value); } return returnValue; } public Object put(Serializable key, String mapKey, Object value) { boolean returnSet = false; Object returnValue = null; if (_createDeltas()) { //Track delta case Map<String, Object> mapValues = (Map<String, Object>) _deltas .get(key); if (mapValues == null) { mapValues = new InternalMap<String, Object>(); _deltas.put(key, mapValues); } if (mapValues.containsKey(mapKey)) { returnValue = mapValues.put(mapKey, value); returnSet = true; } else { mapValues.put(mapKey, value); } } //Handle change on full map Map<String, Object> mapValues = (Map<String, Object>) _fullState .get(key); if (mapValues == null) { mapValues = new InternalMap<String, Object>(); _fullState.put(key, mapValues); } if (returnSet) { mapValues.put(mapKey, value); } else { returnValue = mapValues.put(mapKey, value); } return returnValue; } public Object remove(Serializable key) { Object returnValue = null; if (_createDeltas()) { if (_deltas.containsKey(key)) { // Keep track of the removed values using key/null pair on the delta map returnValue = _deltas.put(key, null); _fullState.remove(key); } else { // Keep track of the removed values using key/null pair on the delta map _deltas.put(key, null); returnValue = _fullState.remove(key); } } else { returnValue = _fullState.remove(key); } return returnValue; } public Object remove(Serializable key, Object valueOrKey) { // Comment by lu4242 : The spec javadoc says if it is a Collection // or Map deal with it. But the intention of this method is work // with add(?,?) and put(?,?,?), this ones return instances of // InternalMap and InternalList to prevent mixing, so to be // consistent we'll cast to those classes here. Object collectionOrMap = _fullState.get(key); Object returnValue = null; if (collectionOrMap instanceof InternalMap) { if (_createDeltas()) { returnValue = _removeValueOrKeyFromMap(_deltas, key, valueOrKey, true); _removeValueOrKeyFromMap(_fullState, key, valueOrKey, false); } else { returnValue = _removeValueOrKeyFromMap(_fullState, key, valueOrKey, false); } } else if (collectionOrMap instanceof InternalList) { if (_createDeltas()) { returnValue = _removeValueOrKeyFromCollectionDelta(_deltas, key, valueOrKey); _removeValueOrKeyFromCollection(_fullState, key, valueOrKey); } else { returnValue = _removeValueOrKeyFromCollection(_fullState, key, valueOrKey); } } return returnValue; } private static Object _removeValueOrKeyFromCollectionDelta( Map<Serializable, Object> stateMap, Serializable key, Object valueOrKey) { Object returnValue = null; Map<Object, Boolean> c = (Map<Object, Boolean>) stateMap.get(key); if (c != null) { if (c.containsKey(valueOrKey)) { returnValue = valueOrKey; } c.put(valueOrKey, Boolean.FALSE); } return returnValue; } private static Object _removeValueOrKeyFromCollection( Map<Serializable, Object> stateMap, Serializable key, Object valueOrKey) { Object returnValue = null; Collection c = (Collection) stateMap.get(key); if (c != null) { if (c.remove(valueOrKey)) { returnValue = valueOrKey; } if (c.isEmpty()) { stateMap.remove(key); } } return returnValue; } private static Object _removeValueOrKeyFromMap( Map<Serializable, Object> stateMap, Serializable key, Object valueOrKey, boolean delta) { if (valueOrKey == null) { return null; } Object returnValue = null; Map<String, Object> map = (Map<String, Object>) stateMap.get(key); if (map != null) { if (delta) { // Keep track of the removed values using key/null pair on the delta map returnValue = map.put((String) valueOrKey, null); } else { returnValue = map.remove(valueOrKey); } if (map.isEmpty()) { //stateMap.remove(key); stateMap.put(key, null); } } return returnValue; } public boolean isTransient() { return _transient; } /** * Serializing cod * the serialized data structure consists of key value pairs unless the value itself is an internal array * or a map in case of an internal array or map the value itself is another array with its initial value * myfaces.InternalArray, myfaces.internalMap * * the internal Array is then mapped to another array * * the internal Map again is then mapped to a map with key value pairs * * */ public Object saveState(FacesContext context) { Map serializableMap = (isInitialStateMarked()) ? _deltas : _fullState; if (serializableMap == null || serializableMap.size() == 0) |
File | Line |
---|---|
javax/faces/component/_DeltaStateHelper.java | 658 |
javax/faces/component/behavior/_AjaxBehaviorDeltaStateHelper.java | 497 |
for (int cnt = 0; cnt < serializedState.length; cnt += 2) { Serializable key = (Serializable) serializedState[cnt]; Object savedValue = UIComponentBase.restoreAttachedState(context, serializedState[cnt + 1]); if (isInitialStateMarked()) { if (savedValue instanceof InternalDeltaListMap) { for (Map.Entry<Object, Boolean> mapEntry : ((Map<Object, Boolean>) savedValue) .entrySet()) { boolean addOrRemove = mapEntry.getValue(); if (addOrRemove) { //add this.add(key, mapEntry.getKey()); } else { //remove this.remove(key, mapEntry.getKey()); } } } else if (savedValue instanceof InternalMap) { for (Map.Entry<String, Object> mapEntry : ((Map<String, Object>) savedValue) .entrySet()) { this.put(key, mapEntry.getKey(), mapEntry.getValue()); } } /* else if (savedValue instanceof _AttachedDeltaWrapper) { _AttachedStateWrapper wrapper = (_AttachedStateWrapper) savedValue; //Restore delta state ((PartialStateHolder)_fullState.get(key)).restoreState(context, wrapper.getWrappedStateObject()); //Add this key as StateHolder key _stateHolderKeys.add(key); } */ else { put(key, savedValue); } } else { put(key, savedValue); } } } public void setTransient(boolean transientValue) { _transient = transientValue; } //We use our own data structures just to make sure //nothing gets mixed up internally static class InternalMap<K, V> extends HashMap<K, V> implements StateHolder { public InternalMap() { super(); } public InternalMap(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); } public InternalMap(Map<? extends K, ? extends V> m) { super(m); } public InternalMap(int initialSize) { super(initialSize); } public boolean isTransient() { return false; } public void setTransient(boolean newTransientValue) { // No op } public void restoreState(FacesContext context, Object state) { Object[] listAsMap = (Object[]) state; for (int cnt = 0; cnt < listAsMap.length; cnt += 2) { this.put((K) listAsMap[cnt], (V) UIComponentBase .restoreAttachedState(context, listAsMap[cnt + 1])); } } public Object saveState(FacesContext context) { int cnt = 0; Object[] mapArr = new Object[this.size() * 2]; for (Map.Entry<K, V> entry : this.entrySet()) { mapArr[cnt] = entry.getKey(); Object value = entry.getValue(); if (value instanceof StateHolder || value instanceof List || !(value instanceof Serializable)) { mapArr[cnt + 1] = UIComponentBase.saveAttachedState(context, value); } else { mapArr[cnt + 1] = value; } cnt += 2; } return mapArr; } } /** * Map used to keep track of list changes */ static class InternalDeltaListMap<K, V> extends InternalMap<K, V> { public InternalDeltaListMap() { super(); } public InternalDeltaListMap(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); } public InternalDeltaListMap(int initialSize) { super(initialSize); } public InternalDeltaListMap(Map<? extends K, ? extends V> m) { super(m); } } static class InternalList<T> extends ArrayList<T> implements StateHolder { public InternalList() { super(); } public InternalList(Collection<? extends T> c) { super(c); } public InternalList(int initialSize) { super(initialSize); } public boolean isTransient() { return false; } public void setTransient(boolean newTransientValue) { } public void restoreState(FacesContext context, Object state) { Object[] listAsArr = (Object[]) state; //since all other options would mean dual iteration //we have to do it the hard way for (Object elem : listAsArr) { add((T) UIComponentBase.restoreAttachedState(context, elem)); } } public Object saveState(FacesContext context) { Object[] values = new Object[size()]; for (int i = 0; i < size(); i++) { Object value = get(i); if (value instanceof StateHolder || value instanceof List || !(value instanceof Serializable)) { values[i] = UIComponentBase.saveAttachedState(context, value); } else { values[i] = value; } } return values; } } |
File | Line |
---|---|
javax/faces/component/_DeltaStateHelper.java | 290 |
javax/faces/component/behavior/_AjaxBehaviorDeltaStateHelper.java | 181 |
} else { _deltas.put(key, value); returnValue = _fullState.put(key, value); } } else { /* if (value instanceof StateHolder) { _stateHolderKeys.add(key); } */ returnValue = _fullState.put(key, value); } return returnValue; } public Object put(Serializable key, String mapKey, Object value) { boolean returnSet = false; Object returnValue = null; if (_createDeltas()) { //Track delta case Map<String, Object> mapValues = (Map<String, Object>) _deltas .get(key); if (mapValues == null) { mapValues = new InternalMap<String, Object>(); _deltas.put(key, mapValues); } if (mapValues.containsKey(mapKey)) { returnValue = mapValues.put(mapKey, value); returnSet = true; } else { mapValues.put(mapKey, value); } } //Handle change on full map Map<String, Object> mapValues = (Map<String, Object>) _fullState .get(key); if (mapValues == null) { mapValues = new InternalMap<String, Object>(); _fullState.put(key, mapValues); } if (returnSet) { mapValues.put(mapKey, value); } else { returnValue = mapValues.put(mapKey, value); } return returnValue; } public Object remove(Serializable key) { Object returnValue = null; if (_createDeltas()) { if (_deltas.containsKey(key)) { // Keep track of the removed values using key/null pair on the delta map returnValue = _deltas.put(key, null); _fullState.remove(key); } else { // Keep track of the removed values using key/null pair on the delta map _deltas.put(key, null); returnValue = _fullState.remove(key); } } else { returnValue = _fullState.remove(key); } return returnValue; } public Object remove(Serializable key, Object valueOrKey) { // Comment by lu4242 : The spec javadoc says if it is a Collection // or Map deal with it. But the intention of this method is work // with add(?,?) and put(?,?,?), this ones return instances of // InternalMap and InternalList to prevent mixing, so to be // consistent we'll cast to those classes here. Object collectionOrMap = _fullState.get(key); Object returnValue = null; if (collectionOrMap instanceof InternalMap) { if (_createDeltas()) { returnValue = _removeValueOrKeyFromMap(_deltas, key, valueOrKey, true); _removeValueOrKeyFromMap(_fullState, key, valueOrKey, false); } else { returnValue = _removeValueOrKeyFromMap(_fullState, key, valueOrKey, false); } } else if (collectionOrMap instanceof InternalList) { if (_createDeltas()) { returnValue = _removeValueOrKeyFromCollectionDelta(_deltas, key, valueOrKey); _removeValueOrKeyFromCollection(_fullState, key, valueOrKey); } else { returnValue = _removeValueOrKeyFromCollection(_fullState, key, valueOrKey); } } return returnValue; } private static Object _removeValueOrKeyFromCollectionDelta( Map<Serializable, Object> stateMap, Serializable key, Object valueOrKey) { Object returnValue = null; Map<Object, Boolean> c = (Map<Object, Boolean>) stateMap.get(key); if (c != null) { if (c.containsKey(valueOrKey)) { returnValue = valueOrKey; } c.put(valueOrKey, Boolean.FALSE); } return returnValue; } private static Object _removeValueOrKeyFromCollection( Map<Serializable, Object> stateMap, Serializable key, Object valueOrKey) { Object returnValue = null; Collection c = (Collection) stateMap.get(key); if (c != null) { if (c.remove(valueOrKey)) { returnValue = valueOrKey; } if (c.isEmpty()) { stateMap.remove(key); } } return returnValue; } private static Object _removeValueOrKeyFromMap( Map<Serializable, Object> stateMap, Serializable key, Object valueOrKey, boolean delta) { if (valueOrKey == null) { return null; } Object returnValue = null; Map<String, Object> map = (Map<String, Object>) stateMap.get(key); if (map != null) { if (delta) { // Keep track of the removed values using key/null pair on the delta map returnValue = map.put((String) valueOrKey, null); } else { returnValue = map.remove(valueOrKey); } if (map.isEmpty()) { //stateMap.remove(key); stateMap.put(key, null); } } return returnValue; } public boolean isTransient() { return _transient; } /** * Serializing cod * the serialized data structure consists of key value pairs unless the value itself is an internal array * or a map in case of an internal array or map the value itself is another array with its initial value * myfaces.InternalArray, myfaces.internalMap * <p/> * the internal Array is then mapped to another array * <p/> * the internal Map again is then mapped to a map with key value pairs */ public Object saveState(FacesContext context) { Map serializableMap = (isInitialStateMarked()) ? _deltas : _fullState; if (serializableMap == null || serializableMap.size() == 0) |
File | Line |
---|---|
javax/faces/convert/_MessageUtils.java | 64 |
javax/faces/validator/_MessageUtils.java | 69 |
appBundle = getApplicationBundle(facesContext, locale); summary = getBundleString(appBundle, messageId); if (summary != null) { detail = getBundleString(appBundle, messageId + DETAIL_SUFFIX); } else { defBundle = getDefaultBundle(facesContext, locale); summary = getBundleString(defBundle, messageId); if (summary != null) { detail = getBundleString(defBundle, messageId + DETAIL_SUFFIX); } else { //Try to find detail alone detail = getBundleString(appBundle, messageId + DETAIL_SUFFIX); if (detail != null) { summary = null; } else { detail = getBundleString(defBundle, messageId + DETAIL_SUFFIX); if (detail != null) { summary = null; } else { //Neither detail nor summary found facesContext.getExternalContext().log("No message with id " + messageId + " found in any bundle"); return new FacesMessage(severity, messageId, null); } } } } if (args != null && args.length > 0) { return new _ParametrizableFacesMessage(severity, summary, detail, args, locale); } else { return new FacesMessage(severity, summary, detail); } } private static String getBundleString(ResourceBundle bundle, String key) { try { return bundle == null ? null : bundle.getString(key); } catch (MissingResourceException e) { return null; } } private static ResourceBundle getApplicationBundle(FacesContext facesContext, Locale locale) { String bundleName = facesContext.getApplication().getMessageBundle(); return bundleName != null ? getBundle(facesContext, locale, bundleName) : null; } private static ResourceBundle getDefaultBundle(FacesContext facesContext, Locale locale) { return getBundle(facesContext, locale, FacesMessage.FACES_MESSAGES); } private static ResourceBundle getBundle(FacesContext facesContext, Locale locale, String bundleName) { try { //First we try the JSF implementation class loader return ResourceBundle.getBundle(bundleName, locale, facesContext.getClass().getClassLoader()); } catch (MissingResourceException ignore1) { try { //Next we try the JSF API class loader return ResourceBundle.getBundle(bundleName, locale, _MessageUtils.class.getClassLoader()); } catch (MissingResourceException ignore2) { try { //Last resort is the context class loader if (System.getSecurityManager() != null) { Object cl = AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws PrivilegedActionException { return Thread.currentThread().getContextClassLoader(); } }); return ResourceBundle.getBundle(bundleName,locale,(ClassLoader)cl); } else { return ResourceBundle.getBundle(bundleName,locale, Thread.currentThread().getContextClassLoader()); } } catch(PrivilegedActionException pae) { throw new FacesException(pae); } catch (MissingResourceException damned) { facesContext.getExternalContext().log("resource bundle " + bundleName + " could not be found"); return null; } } } } static Object getLabel(FacesContext facesContext, UIComponent component) { Object label = component.getAttributes().get("label"); ValueExpression expression = null; if (label != null && label instanceof String && ((String)label).length() == 0 ) { // Note component.getAttributes().get("label") internally try to // evaluate the EL expression for the label, but in some cases, // when PSS is disabled and f:loadBundle is used, when the view is // restored the bundle is not set to the EL expression returns an // empty String. It is not possible to check if there is a // hardcoded label, but we can check if there is // an EL expression set, so the best in this case is use that, and if // there is an EL expression set, use it, otherwise use the hardcoded // value. See MYFACES-3591 for details. expression = component.getValueExpression("label"); if (expression != null) { // Set the label to null and use the EL expression instead. label = null; } } if(label != null) { return label; } expression = (expression == null) ? component.getValueExpression("label") : expression; if(expression != null) { return expression; } //If no label is not specified, use clientId return component.getClientId( facesContext ); } } |
File | Line |
---|---|
javax/faces/component/_ParametrizableFacesMessage.java | 36 |
javax/faces/validator/_ParametrizableFacesMessage.java | 36 |
class _ParametrizableFacesMessage extends FacesMessage { /** * */ private static final long serialVersionUID = 7792947730961657948L; private final Object _args[]; private String _evaluatedDetail; private String _evaluatedSummary; private transient Object _evaluatedArgs[]; private Locale _locale; public _ParametrizableFacesMessage( String summary, String detail, Object[] args, Locale locale) { super(summary, detail); if(locale == null) { throw new NullPointerException("locale"); } _locale = locale; _args = args; } public _ParametrizableFacesMessage(FacesMessage.Severity severity, String summary, String detail, Object[] args, Locale locale) { super(severity, summary, detail); if(locale == null) { throw new NullPointerException("locale"); } _locale = locale; _args = args; } @Override public String getDetail() { if (_evaluatedArgs == null && _args != null) { evaluateArgs(); } if (_evaluatedDetail == null) { MessageFormat format = new MessageFormat(super.getDetail(), _locale); _evaluatedDetail = format.format(_evaluatedArgs); } return _evaluatedDetail; } @Override public void setDetail(String detail) { super.setDetail(detail); _evaluatedDetail = null; } public String getUnformattedDetail() { return super.getDetail(); } @Override public String getSummary() { if (_evaluatedArgs == null && _args != null) { evaluateArgs(); } if (_evaluatedSummary == null) { MessageFormat format = new MessageFormat(super.getSummary(), _locale); _evaluatedSummary = format.format(_evaluatedArgs); } return _evaluatedSummary; } @Override public void setSummary(String summary) { super.setSummary(summary); _evaluatedSummary = null; } public String getUnformattedSummary() { return super.getSummary(); } private void evaluateArgs() { _evaluatedArgs = new Object[_args.length]; FacesContext facesContext = null; for (int i = 0; i < _args.length; i++) { if (_args[i] == null) { continue; } else if (_args[i] instanceof ValueBinding) { if (facesContext == null) { facesContext = FacesContext.getCurrentInstance(); } _evaluatedArgs[i] = ((ValueBinding)_args[i]).getValue(facesContext); } else if (_args[i] instanceof ValueExpression) { if (facesContext == null) { facesContext = FacesContext.getCurrentInstance(); } _evaluatedArgs[i] = ((ValueExpression)_args[i]).getValue(facesContext.getELContext()); } else { _evaluatedArgs[i] = _args[i]; } } } } |
File | Line |
---|---|
javax/faces/component/_DeltaStateHelper.java | 661 |
javax/faces/component/behavior/_DeltaStateHelper.java | 616 |
Object savedValue = restoreAttachedState(context, serializedState[cnt + 1]); if (isInitialStateMarked()) { if (savedValue instanceof InternalDeltaListMap) { for (Map.Entry<Object, Boolean> mapEntry : ((Map<Object, Boolean>) savedValue) .entrySet()) { boolean addOrRemove = mapEntry.getValue(); if (addOrRemove) { //add this.add(key, mapEntry.getKey()); } else { //remove this.remove(key, mapEntry.getKey()); } } } else if (savedValue instanceof InternalMap) { for (Map.Entry<String, Object> mapEntry : ((Map<String, Object>) savedValue) .entrySet()) { this.put(key, mapEntry.getKey(), mapEntry.getValue()); } } /* else if (savedValue instanceof _AttachedDeltaWrapper) { _AttachedStateWrapper wrapper = (_AttachedStateWrapper) savedValue; //Restore delta state ((PartialStateHolder)_fullState.get(key)).restoreState(context, wrapper.getWrappedStateObject()); //Add this key as StateHolder key _stateHolderKeys.add(key); } */ else { put(key, savedValue); } } else { put(key, savedValue); } } } public void setTransient(boolean transientValue) { _transient = transientValue; } //We use our own data structures just to make sure //nothing gets mixed up internally static class InternalMap<K, V> extends HashMap<K, V> implements StateHolder { public InternalMap() { super(); } public InternalMap(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); } public InternalMap(Map<? extends K, ? extends V> m) { super(m); } public InternalMap(int initialSize) { super(initialSize); } public boolean isTransient() { return false; } public void setTransient(boolean newTransientValue) { // No op } public void restoreState(FacesContext context, Object state) { Object[] listAsMap = (Object[]) state; for (int cnt = 0; cnt < listAsMap.length; cnt += 2) { this.put((K) listAsMap[cnt], (V) UIComponentBase .restoreAttachedState(context, listAsMap[cnt + 1])); } } public Object saveState(FacesContext context) { int cnt = 0; Object[] mapArr = new Object[this.size() * 2]; for (Map.Entry<K, V> entry : this.entrySet()) { mapArr[cnt] = entry.getKey(); Object value = entry.getValue(); if (value instanceof StateHolder || value instanceof List || !(value instanceof Serializable)) { mapArr[cnt + 1] = saveAttachedState(context, value); |
File | Line |
---|---|
javax/faces/component/behavior/BehaviorBase.java | 154 |
javax/faces/component/behavior/_DeltaStateHelper.java | 826 |
} } private static Object saveAttachedState(FacesContext context, Object attachedObject) { if (context == null) { throw new NullPointerException ("context"); } if (attachedObject == null) { return null; } // StateHolder interface should take precedence over // List children if (attachedObject instanceof StateHolder) { StateHolder holder = (StateHolder) attachedObject; if (holder.isTransient()) { return null; } return new _AttachedStateWrapper(attachedObject.getClass(), holder.saveState(context)); } else if (attachedObject instanceof List) { List<Object> lst = new ArrayList<Object>(((List<?>) attachedObject).size()); for (Object item : (List<?>) attachedObject) { if (item != null) { lst.add(saveAttachedState(context, item)); } } return new _AttachedListStateWrapper(lst); } else if (attachedObject instanceof Serializable) { return attachedObject; } else { return new _AttachedStateWrapper(attachedObject.getClass(), null); } } private static Object restoreAttachedState(FacesContext context, Object stateObj) throws IllegalStateException { if (context == null) { throw new NullPointerException("context"); } if (stateObj == null) { return null; } if (stateObj instanceof _AttachedListStateWrapper) { List<Object> lst = ((_AttachedListStateWrapper) stateObj).getWrappedStateList(); List<Object> restoredList = new ArrayList<Object>(lst.size()); for (Object item : lst) { restoredList.add(restoreAttachedState(context, item)); } return restoredList; } else if (stateObj instanceof _AttachedStateWrapper) { Class<?> clazz = ((_AttachedStateWrapper) stateObj).getClazz(); Object restoredObject; try { restoredObject = clazz.newInstance(); } catch (InstantiationException e) { throw new RuntimeException("Could not restore StateHolder of type " + clazz.getName() + " (missing no-args constructor?)", e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } if (restoredObject instanceof StateHolder) { _AttachedStateWrapper wrapper = (_AttachedStateWrapper) stateObj; Object wrappedState = wrapper.getWrappedStateObject(); StateHolder holder = (StateHolder) restoredObject; holder.restoreState(context, wrappedState); } return restoredObject; } else { return stateObj; } } |
File | Line |
---|---|
javax/faces/component/behavior/_AjaxBehaviorDeltaStateHelper.java | 78 |
javax/faces/component/behavior/_DeltaStateHelper.java | 180 |
_fullState = new HashMap<Serializable, Object>(); _deltas = null; //_stateHolderKeys = new HashSet<Serializable>(); } /** * Used to create delta map on demand * * @return */ private boolean _createDeltas() { if (isInitialStateMarked()) { if (_deltas == null) { _deltas = new HashMap<Serializable, Object>(2); } return true; } return false; } protected boolean isInitialStateMarked() { return _target.initialStateMarked(); } public void add(Serializable key, Object value) { if (_createDeltas()) { //Track delta case Map<Object, Boolean> deltaListMapValues = (Map<Object, Boolean>) _deltas .get(key); if (deltaListMapValues == null) { deltaListMapValues = new InternalDeltaListMap<Object, Boolean>( 3); _deltas.put(key, deltaListMapValues); } deltaListMapValues.put(value, Boolean.TRUE); } //Handle change on full map List<Object> fullListValues = (List<Object>) _fullState.get(key); if (fullListValues == null) { fullListValues = new InternalList<Object>(3); _fullState.put(key, fullListValues); } fullListValues.add(value); } public Object eval(Serializable key) { Object returnValue = _fullState.get(key); if (returnValue != null) { return returnValue; } ValueExpression expression = _target.getValueExpression(key .toString()); if (expression != null) { return expression.getValue(FacesContext.getCurrentInstance() .getELContext()); } return null; } public Object eval(Serializable key, Object defaultValue) { Object returnValue = _fullState.get(key); if (returnValue != null) { return returnValue; } ValueExpression expression = _target.getValueExpression(key .toString()); if (expression != null) { return expression.getValue(FacesContext.getCurrentInstance() .getELContext()); } return defaultValue; } public Object get(Serializable key) { return _fullState.get(key); } public Object put(Serializable key, Object value) { Object returnValue = null; if (_createDeltas()) { if (_deltas.containsKey(key)) { returnValue = _deltas.put(key, value); _fullState.put(key, value); } else if (value == null && !_fullState.containsKey(key)) |
File | Line |
---|---|
javax/faces/component/_MessageUtils.java | 66 |
javax/faces/convert/_MessageUtils.java | 50 |
args); } static FacesMessage getMessage(FacesContext facesContext, Locale locale, FacesMessage.Severity severity, String messageId, Object args[]) { ResourceBundle appBundle; ResourceBundle defBundle; String summary; String detail; appBundle = getApplicationBundle(facesContext, locale); summary = getBundleString(appBundle, messageId); if (summary != null) { detail = getBundleString(appBundle, messageId + DETAIL_SUFFIX); } else { defBundle = getDefaultBundle(facesContext, locale); summary = getBundleString(defBundle, messageId); if (summary != null) { detail = getBundleString(defBundle, messageId + DETAIL_SUFFIX); } else { //Try to find detail alone detail = getBundleString(appBundle, messageId + DETAIL_SUFFIX); if (detail != null) { summary = null; } else { detail = getBundleString(defBundle, messageId + DETAIL_SUFFIX); if (detail != null) { summary = null; } else { //Neither detail nor summary found facesContext.getExternalContext().log("No message with id " + messageId + " found in any bundle"); return new FacesMessage(severity, messageId, null); } } } } if (args != null && args.length > 0) { return new _ParametrizableFacesMessage(severity, summary, detail, args, locale); } else { return new FacesMessage(severity, summary, detail); } } private static String getBundleString(ResourceBundle bundle, String key) { try { return bundle == null ? null : bundle.getString(key); } catch (MissingResourceException e) { return null; } } private static ResourceBundle getApplicationBundle(FacesContext facesContext, Locale locale) { String bundleName = facesContext.getApplication().getMessageBundle(); return bundleName != null ? getBundle(facesContext, locale, bundleName) : null; } private static ResourceBundle getDefaultBundle(FacesContext facesContext, Locale locale) { return getBundle(facesContext, locale, FacesMessage.FACES_MESSAGES); } private static ResourceBundle getBundle(FacesContext facesContext, Locale locale, String bundleName) { try { //First we try the JSF implementation class loader return ResourceBundle.getBundle(bundleName, locale, facesContext.getClass().getClassLoader()); } catch (MissingResourceException ignore1) { try { //Next we try the JSF API class loader return ResourceBundle.getBundle(bundleName, locale, _MessageUtils.class.getClassLoader()); } catch (MissingResourceException ignore2) { try { |
File | Line |
---|---|
javax/faces/component/_MessageUtils.java | 81 |
javax/faces/validator/_MessageUtils.java | 69 |
appBundle = getApplicationBundle(facesContext, locale); summary = getBundleString(appBundle, messageId); if (summary != null) { detail = getBundleString(appBundle, messageId + DETAIL_SUFFIX); } else { defBundle = getDefaultBundle(facesContext, locale); summary = getBundleString(defBundle, messageId); if (summary != null) { detail = getBundleString(defBundle, messageId + DETAIL_SUFFIX); } else { //Try to find detail alone detail = getBundleString(appBundle, messageId + DETAIL_SUFFIX); if (detail != null) { summary = null; } else { detail = getBundleString(defBundle, messageId + DETAIL_SUFFIX); if (detail != null) { summary = null; } else { //Neither detail nor summary found facesContext.getExternalContext().log("No message with id " + messageId + " found in any bundle"); return new FacesMessage(severity, messageId, null); } } } } if (args != null && args.length > 0) { return new _ParametrizableFacesMessage(severity, summary, detail, args, locale); } else { return new FacesMessage(severity, summary, detail); } } private static String getBundleString(ResourceBundle bundle, String key) { try { return bundle == null ? null : bundle.getString(key); } catch (MissingResourceException e) { return null; } } private static ResourceBundle getApplicationBundle(FacesContext facesContext, Locale locale) { String bundleName = facesContext.getApplication().getMessageBundle(); return bundleName != null ? getBundle(facesContext, locale, bundleName) : null; } private static ResourceBundle getDefaultBundle(FacesContext facesContext, Locale locale) { return getBundle(facesContext, locale, FacesMessage.FACES_MESSAGES); } private static ResourceBundle getBundle(FacesContext facesContext, Locale locale, String bundleName) { try { //First we try the JSF implementation class loader return ResourceBundle.getBundle(bundleName, locale, facesContext.getClass().getClassLoader()); } catch (MissingResourceException ignore1) { try { //Next we try the JSF API class loader return ResourceBundle.getBundle(bundleName, locale, _MessageUtils.class.getClassLoader()); } catch (MissingResourceException ignore2) { try { |
File | Line |
---|---|
javax/faces/component/UIData.java | 900 |
javax/faces/component/UIData.java | 981 |
UIComponent child = parent.getChildren().get(i); if (!child.isTransient()) { // Add an entry to the collection, being an array of two // elements. The first element is the state of the children // of this component; the second is the state of the current // child itself. if (child instanceof EditableValueHolder) { if (childStates == null) { childStates = new ArrayList<Object[]>( parent.getFacetCount() + parent.getChildCount() - totalChildCount + childEmptyIndex); for (int ci = 0; ci < childEmptyIndex; ci++) { childStates.add(LEAF_NO_STATE); } } childStates.add(child.getChildCount() > 0 ? new Object[]{new EditableValueHolderState((EditableValueHolder) child), saveDescendantComponentStates(child, saveChildFacets, true)} : new Object[]{new EditableValueHolderState((EditableValueHolder) child), null}); } else if (child.getChildCount() > 0 || (saveChildFacets && child.getFacetCount() > 0)) { Object descendantSavedState = saveDescendantComponentStates(child, saveChildFacets, true); if (descendantSavedState == null) { if (childStates == null) { childEmptyIndex++; } else { childStates.add(LEAF_NO_STATE); } } else { if (childStates == null) { childStates = new ArrayList<Object[]>( parent.getFacetCount() + parent.getChildCount() - totalChildCount + childEmptyIndex); for (int ci = 0; ci < childEmptyIndex; ci++) { childStates.add(LEAF_NO_STATE); } } childStates.add(new Object[]{null, descendantSavedState}); } } else { if (childStates == null) { childEmptyIndex++; } else { childStates.add(LEAF_NO_STATE); } } } totalChildCount++; } } |
File | Line |
---|---|
javax/faces/event/MethodExpressionActionListener.java | 82 |
javax/faces/event/MethodExpressionValueChangeListener.java | 80 |
Object[] params = new Object[] { event }; methodExpressionOneArg.invoke(getElContext(), params); } catch (MethodNotFoundException mnfe) { // call to the zero argument MethodExpression methodExpressionZeroArg.invoke(getElContext(), EMPTY_PARAMS); } } catch (ELException e) { // "... If that fails for any reason, throw an AbortProcessingException, // including the cause of the failure ..." // -= Leonardo Uribe =- after discussing this topic on MYFACES-3199, the conclusion is the part is an advice // for the developer implementing a listener in a method expressions that could be wrapped by this class. // The spec wording is poor but, to keep this coherently with ExceptionHandler API, // the spec and code on UIViewRoot we need: // 2a) "exception is instance of APE or any of the causes of the exception are an APE, // DON'T publish ExceptionQueuedEvent and terminate processing for current event". // 2b) for any other exception publish ExceptionQueuedEvent and continue broadcast processing. Throwable cause = e.getCause(); AbortProcessingException ape = null; if (cause != null) { do { if (cause != null && cause instanceof AbortProcessingException) { ape = (AbortProcessingException) cause; break; } cause = cause.getCause(); } while (cause != null); } if (ape != null) { // 2a) "exception is instance of APE or any of the causes of the exception are an APE, // DON'T publish ExceptionQueuedEvent and terminate processing for current event". // To do this throw an AbortProcessingException here, later on UIViewRoot.broadcastAll, // this exception will be received and stored to handle later. throw ape; } //for any other exception publish ExceptionQueuedEvent and continue broadcast processing. throw e; //Throwable cause = e.getCause(); //if (cause == null) //{ // cause = e; //} //if (cause instanceof AbortProcessingException) //{ // throw (AbortProcessingException) cause; //} //else //{ // throw new AbortProcessingException(cause); //} } } public void restoreState(FacesContext context, Object state) { methodExpressionOneArg = (MethodExpression) ((Object[]) state)[0]; methodExpressionZeroArg = (MethodExpression) ((Object[]) state)[1]; } public Object saveState(FacesContext context) { return new Object[] {methodExpressionOneArg, methodExpressionZeroArg}; } public void setTransient(boolean newTransientValue) { isTransient = newTransientValue; } public boolean isTransient() { return isTransient; } private ELContext getElContext() { return getFacesContext().getELContext(); } private FacesContext getFacesContext() { return FacesContext.getCurrentInstance(); } /** * Creates a {@link MethodExpression} with no params and with the same Expression as * param <code>methodExpression</code> * <b>WARNING!</b> This method creates new {@link MethodExpression} with expressionFactory.createMethodExpression. * That means is not decorating MethodExpression passed as parameter - * support for EL VariableMapper will not be available! * This is a problem when using facelets and <ui:decorate/> with EL params (see MYFACES-2541 for details). */ private void _createZeroArgsMethodExpression(MethodExpression methodExpression) { ExpressionFactory expressionFactory = getFacesContext().getApplication().getExpressionFactory(); this.methodExpressionZeroArg = expressionFactory.createMethodExpression(getElContext(), methodExpression.getExpressionString(), Void.class, EMPTY_CLASS_ARRAY); } } |
File | Line |
---|---|
javax/faces/component/UIComponentBase.java | 1662 |
javax/faces/component/UIForm.java | 398 |
} private String getComponentLocation(UIComponent component) { Location location = (Location) component.getAttributes() .get(UIComponent.VIEW_LOCATION_KEY); if (location != null) { return location.toString(); } return null; } private String getPathToComponent(UIComponent component) { StringBuffer buf = new StringBuffer(); if (component == null) { buf.append("{Component-Path : "); buf.append("[null]}"); return buf.toString(); } getPathToComponent(component, buf); buf.insert(0, "{Component-Path : "); buf.append("}"); return buf.toString(); } private void getPathToComponent(UIComponent component, StringBuffer buf) { if (component == null) { return; } StringBuffer intBuf = new StringBuffer(); intBuf.append("[Class: "); intBuf.append(component.getClass().getName()); if (component instanceof UIViewRoot) { intBuf.append(",ViewId: "); intBuf.append(((UIViewRoot) component).getViewId()); } else { intBuf.append(",Id: "); intBuf.append(component.getId()); } intBuf.append("]"); buf.insert(0, intBuf.toString()); getPathToComponent(component.getParent(), buf); } |
File | Line |
---|---|
javax/faces/component/UIForm.java | 310 |
javax/faces/component/UINamingContainer.java | 138 |
{ boolean isCachedFacesContext = isCachedFacesContext(); try { if (!isCachedFacesContext) { setCachedFacesContext(context.getFacesContext()); } if (!isVisitable(context)) { return false; } pushComponentToEL(context.getFacesContext(), this); try { VisitResult res = context.invokeVisitCallback(this, callback); switch (res) { //we are done nothing has to be processed anymore case COMPLETE: return true; case REJECT: return false; //accept default: // Take advantage of the fact this is a NamingContainer // and we can know if there are ids to visit inside it Collection<String> subtreeIdsToVisit = context.getSubtreeIdsToVisit(this); if (subtreeIdsToVisit != null && !subtreeIdsToVisit.isEmpty()) { if (getFacetCount() > 0) { for (UIComponent facet : getFacets().values()) { if (facet.visitTree(context, callback)) { return true; } } } for (int i = 0, childCount = getChildCount(); i < childCount; i++) { UIComponent child = getChildren().get(i); if (child.visitTree(context, callback)) { return true; } } } return false; } } finally { //all components must call popComponentFromEl after visiting is finished popComponentFromEL(context.getFacesContext()); } } finally { if (!isCachedFacesContext) { setCachedFacesContext(null); } } } |
File | Line |
---|---|
javax/faces/component/_LabeledFacesMessage.java | 32 |
javax/faces/convert/_LabeledFacesMessage.java | 32 |
class _LabeledFacesMessage extends FacesMessage { public _LabeledFacesMessage() { super(); } public _LabeledFacesMessage(Severity severity, String summary, String detail, Object args[]) { super(severity, summary, detail); } public _LabeledFacesMessage(Severity severity, String summary, String detail) { super(severity, summary, detail); } public _LabeledFacesMessage(String summary, String detail) { super(summary, detail); } public _LabeledFacesMessage(String summary) { super(summary); } @Override public String getDetail() { FacesContext facesContext = FacesContext.getCurrentInstance(); ValueExpression value = facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), super.getDetail(), String.class); return (String)value.getValue(facesContext.getELContext()); } @Override public String getSummary() { FacesContext facesContext = FacesContext.getCurrentInstance(); ValueExpression value = facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), super.getSummary(), String.class); return (String)value.getValue(facesContext.getELContext()); } } |
File | Line |
---|---|
javax/faces/component/_DeltaStateHelper.java | 776 |
javax/faces/component/behavior/_DeltaStateHelper.java | 731 |
mapArr[cnt + 1] = saveAttachedState(context, value); } else { mapArr[cnt + 1] = value; } cnt += 2; } return mapArr; } } /** * Map used to keep track of list changes */ static class InternalDeltaListMap<K, V> extends InternalMap<K, V> { public InternalDeltaListMap() { super(); } public InternalDeltaListMap(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); } public InternalDeltaListMap(int initialSize) { super(initialSize); } public InternalDeltaListMap(Map<? extends K, ? extends V> m) { super(m); } } static class InternalList<T> extends ArrayList<T> implements StateHolder { public InternalList() { super(); } public InternalList(Collection<? extends T> c) { super(c); } public InternalList(int initialSize) { super(initialSize); } public boolean isTransient() { return false; } public void setTransient(boolean newTransientValue) { } public void restoreState(FacesContext context, Object state) { Object[] listAsArr = (Object[]) state; //since all other options would mean dual iteration //we have to do it the hard way for (Object elem : listAsArr) { add((T) restoreAttachedState(context, elem)); |
File | Line |
---|---|
javax/faces/component/UIComponentBase.java | 1678 |
javax/faces/component/_SelectItemsIterator.java | 322 |
} private String getPathToComponent(UIComponent component) { StringBuffer buf = new StringBuffer(); if (component == null) { buf.append("{Component-Path : "); buf.append("[null]}"); return buf.toString(); } getPathToComponent(component, buf); buf.insert(0, "{Component-Path : "); buf.append("}"); return buf.toString(); } private void getPathToComponent(UIComponent component, StringBuffer buf) { if (component == null) { return; } StringBuffer intBuf = new StringBuffer(); intBuf.append("[Class: "); intBuf.append(component.getClass().getName()); if (component instanceof UIViewRoot) { intBuf.append(",ViewId: "); intBuf.append(((UIViewRoot) component).getViewId()); } else { intBuf.append(",Id: "); intBuf.append(component.getId()); } intBuf.append("]"); buf.insert(0, intBuf); |
File | Line |
---|---|
javax/faces/component/UIData.java | 746 |
javax/faces/component/UIData.java | 789 |
UIComponent component = parent.getChildren().get(i); // reset the client id (see spec 3.1.6) component.setId(component.getId()); if (!component.isTransient()) { if (descendantStateIndex == -1) { stateCollection = ((List<? extends Object[]>) state); descendantStateIndex = stateCollection.isEmpty() ? -1 : 0; } if (descendantStateIndex != -1 && descendantStateIndex < stateCollection.size()) { Object[] object = stateCollection.get(descendantStateIndex); if (object[0] != null && component instanceof EditableValueHolder) { ((EditableValueHolderState) object[0]).restoreState((EditableValueHolder) component); } // If there is descendant state to restore, call it recursively, otherwise // it is safe to skip iteration. if (object[1] != null) { restoreDescendantComponentStates(component, restoreChildFacets, object[1], true); } else { restoreDescendantComponentWithoutRestoreState(component, restoreChildFacets, true); } } else { restoreDescendantComponentWithoutRestoreState(component, restoreChildFacets, true); } descendantStateIndex++; } } } |
File | Line |
---|---|
javax/faces/component/_DeltaStateHelper.java | 209 |
javax/faces/component/behavior/_DeltaStateHelper.java | 206 |
return _target.initialStateMarked(); } public void add(Serializable key, Object value) { if (_createDeltas()) { //Track delta case Map<Object, Boolean> deltaListMapValues = (Map<Object, Boolean>) _deltas .get(key); if (deltaListMapValues == null) { deltaListMapValues = new InternalDeltaListMap<Object, Boolean>( 3); _deltas.put(key, deltaListMapValues); } deltaListMapValues.put(value, Boolean.TRUE); } //Handle change on full map List<Object> fullListValues = (List<Object>) _fullState.get(key); if (fullListValues == null) { fullListValues = new InternalList<Object>(3); _fullState.put(key, fullListValues); } fullListValues.add(value); } public Object eval(Serializable key) { Object returnValue = _fullState.get(key); if (returnValue != null) { return returnValue; } ValueExpression expression = _target.getValueExpression(key |
File | Line |
---|---|
javax/faces/component/_MessageUtils.java | 183 |
javax/faces/convert/_MessageUtils.java | 184 |
throw new FacesException(pae); } catch (MissingResourceException damned) { facesContext.getExternalContext().log("resource bundle " + bundleName + " could not be found"); return null; } } } } static Object getLabel(FacesContext facesContext, UIComponent component) { Object label = component.getAttributes().get("label"); ValueExpression expression = null; if (label != null && label instanceof String && ((String)label).length() == 0 ) { // Note component.getAttributes().get("label") internally try to // evaluate the EL expression for the label, but in some cases, // when PSS is disabled and f:loadBundle is used, when the view is // restored the bundle is not set to the EL expression returns an // empty String. It is not possible to check if there is a // hardcoded label, but we can check if there is // an EL expression set, so the best in this case is use that, and if // there is an EL expression set, use it, otherwise use the hardcoded // value. See MYFACES-3591 for details. expression = component.getValueExpression("label"); if (expression != null) { // Set the label to null and use the EL expression instead. label = null; } } if(label != null) { return label; } expression = (expression == null) ? component.getValueExpression("label") : expression; if(expression != null) { return expression; } //If no label is not specified, use clientId return component.getClientId( facesContext ); } } |
File | Line |
---|---|
javax/faces/component/UIComponentBase.java | 1855 |
javax/faces/component/behavior/BehaviorBase.java | 217 |
for (Object item : lst) { restoredList.add(restoreAttachedState(context, item)); } return restoredList; } else if (stateObj instanceof _AttachedStateWrapper) { Class<?> clazz = ((_AttachedStateWrapper) stateObj).getClazz(); Object restoredObject; try { restoredObject = clazz.newInstance(); } catch (InstantiationException e) { throw new RuntimeException("Could not restore StateHolder of type " + clazz.getName() + " (missing no-args constructor?)", e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } if (restoredObject instanceof StateHolder) { _AttachedStateWrapper wrapper = (_AttachedStateWrapper) stateObj; Object wrappedState = wrapper.getWrappedStateObject(); StateHolder holder = (StateHolder) restoredObject; holder.restoreState(context, wrappedState); } return restoredObject; } else { return stateObj; } } public void setTransient(boolean newTransientValue) |
File | Line |
---|---|
javax/faces/component/UIComponentBase.java | 1855 |
javax/faces/component/behavior/_DeltaStateHelper.java | 889 |
for (Object item : lst) { restoredList.add(restoreAttachedState(context, item)); } return restoredList; } else if (stateObj instanceof _AttachedStateWrapper) { Class<?> clazz = ((_AttachedStateWrapper) stateObj).getClazz(); Object restoredObject; try { restoredObject = clazz.newInstance(); } catch (InstantiationException e) { throw new RuntimeException("Could not restore StateHolder of type " + clazz.getName() + " (missing no-args constructor?)", e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } if (restoredObject instanceof StateHolder) { _AttachedStateWrapper wrapper = (_AttachedStateWrapper) stateObj; Object wrappedState = wrapper.getWrappedStateObject(); StateHolder holder = (StateHolder) restoredObject; holder.restoreState(context, wrappedState); } return restoredObject; } else { return stateObj; } } |
File | Line |
---|---|
javax/faces/model/ArrayDataModel.java | 89 |
javax/faces/model/ScalarDataModel.java | 81 |
} @Override public void setRowIndex(int rowIndex) { if (rowIndex < -1) { throw new IllegalArgumentException("illegal rowIndex " + rowIndex); } int oldRowIndex = _rowIndex; _rowIndex = rowIndex; if (_data != null && oldRowIndex != _rowIndex) { Object data = isRowAvailable() ? getRowData() : null; DataModelEvent event = new DataModelEvent(this, _rowIndex, data); DataModelListener[] listeners = getDataModelListeners(); for (int i = 0; i < listeners.length; i++) { listeners[i].rowSelected(event); } } } @Override public void setWrappedData(Object data) { if (data == null) { setRowIndex(-1); _data = null; } else { _data = (E) data; |
File | Line |
---|---|
javax/faces/component/_DeltaStateHelper.java | 552 |
javax/faces/component/behavior/_DeltaStateHelper.java | 507 |
if (serializableMap == null || serializableMap.size() == 0) { return null; } /* int stateHolderKeyCount = 0; if (isInitalStateMarked()) { for (Iterator<Serializable> it = _stateHolderKeys.iterator(); it.hasNext();) { Serializable key = it.next(); if (!_deltas.containsKey(key)) { stateHolderKeyCount++; } } }*/ Map.Entry<Serializable, Object> entry; //entry == key, value, key, value Object[] retArr = new Object[serializableMap.entrySet().size() * 2]; //Object[] retArr = new Object[serializableMap.entrySet().size() * 2 + stateHolderKeyCount]; Iterator<Map.Entry<Serializable, Object>> it = serializableMap .entrySet().iterator(); int cnt = 0; while (it.hasNext()) { entry = it.next(); retArr[cnt] = entry.getKey(); Object value = entry.getValue(); // The condition in which the call to saveAttachedState // is to handle List, StateHolder or non Serializable instances. // we check it here, to prevent unnecessary calls. if (value instanceof StateHolder || value instanceof List || !(value instanceof Serializable)) { Object savedValue = saveAttachedState(context, |
File | Line |
---|---|
javax/faces/component/_DeltaStateHelper.java | 593 |
javax/faces/component/behavior/_DeltaStateHelper.java | 548 |
Object savedValue = saveAttachedState(context, value); retArr[cnt + 1] = savedValue; } else { retArr[cnt + 1] = value; } cnt += 2; } /* if (isInitalStateMarked()) { for (Iterator<Serializable> it2 = _stateHolderKeys.iterator(); it.hasNext();) { Serializable key = it2.next(); if (!_deltas.containsKey(key)) { retArr[cnt] = key; Object value = _fullState.get(key); if (value instanceof PartialStateHolder) { //Could contain delta, save it as _AttachedDeltaState PartialStateHolder holder = (PartialStateHolder) value; if (holder.isTransient()) { retArr[cnt + 1] = null; } else { retArr[cnt + 1] = new _AttachedDeltaWrapper(value.getClass(), holder.saveState(context)); } } else { //Save everything retArr[cnt + 1] = saveAttachedState(context, _fullState.get(key)); } cnt += 2; } } } */ return retArr; } public void restoreState(FacesContext context, Object state) { if (state == null) { return; } Object[] serializedState = (Object[]) state; if (!isInitialStateMarked() && !_fullState.isEmpty()) { _fullState.clear(); if(_deltas != null) { _deltas.clear(); } } for (int cnt = 0; cnt < serializedState.length; cnt += 2) { Serializable key = (Serializable) serializedState[cnt]; Object savedValue = restoreAttachedState(context, |
File | Line |
---|---|
javax/faces/component/UIData.java | 557 |
javax/faces/component/UIData.java | 658 |
} } _rowIndex = rowIndex; DataModel dataModel = getDataModel(); dataModel.setRowIndex(rowIndex); String var = (String) getStateHelper().get(PropertyKeys.var); if (rowIndex == -1) { if (var != null) { facesContext.getExternalContext().getRequestMap().remove(var); } } else { if (var != null) { if (isRowAvailable()) { Object rowData = dataModel.getRowData(); facesContext.getExternalContext().getRequestMap().put(var, rowData); } else { facesContext.getExternalContext().getRequestMap().remove(var); } } } if (_initialDescendantFullComponentState != null) |
File | Line |
---|---|
javax/faces/validator/LengthValidator.java | 211 |
javax/faces/validator/LongRangeValidator.java | 240 |
if (_minimum != null ? !_minimum.equals(longRangeValidator._minimum) : longRangeValidator._minimum != null) { return false; } return true; } @Override public int hashCode() { int result = _minimum != null ? _minimum.hashCode() : 0; result = 31 * result + (_maximum != null ? _maximum.hashCode() : 0); return result; } private boolean _initialStateMarked = false; public void clearInitialState() { _initialStateMarked = false; } public boolean initialStateMarked() { return _initialStateMarked; } public void markInitialState() { _initialStateMarked = true; } @JSFProperty(faceletsOnly=true) private Boolean isDisabled() { return null; } @JSFProperty(faceletsOnly=true) private String getFor() { return null; } } |
File | Line |
---|---|
javax/faces/component/UIComponentBase.java | 1699 |
javax/faces/component/_ComponentUtils.java | 417 |
private static void getPathToComponent(UIComponent component, StringBuffer buf) { if (component == null) { return; } StringBuffer intBuf = new StringBuffer(); intBuf.append("[Class: "); intBuf.append(component.getClass().getName()); if (component instanceof UIViewRoot) { intBuf.append(",ViewId: "); intBuf.append(((UIViewRoot)component).getViewId()); } else { intBuf.append(",Id: "); intBuf.append(component.getId()); } intBuf.append("]"); buf.insert(0, intBuf.toString()); getPathToComponent(component.getParent(), buf); } |
File | Line |
---|---|
javax/faces/component/_SelectItemsIterator.java | 343 |
javax/faces/webapp/UIComponentClassicTagBase.java | 966 |
private static void getPathToComponent(UIComponent component, StringBuffer buf) { if (component == null) { return; } StringBuffer intBuf = new StringBuffer(); intBuf.append("[Class: "); intBuf.append(component.getClass().getName()); if (component instanceof UIViewRoot) { intBuf.append(",ViewId: "); intBuf.append(((UIViewRoot)component).getViewId()); } else { intBuf.append(",Id: "); intBuf.append(component.getId()); } intBuf.append("]"); buf.insert(0, intBuf); getPathToComponent(component.getParent(), buf); } |
File | Line |
---|---|
javax/faces/component/UIData.java | 1617 |
javax/faces/component/UINamingContainer.java | 64 |
} /** * * {@inheritDoc} * * @since 2.0 */ public String createUniqueId(FacesContext context, String seed) { StringBuilder bld = _getSharedStringBuilder(context); // Generate an identifier for a component. The identifier will be prefixed with UNIQUE_ID_PREFIX, // and will be unique within this UIViewRoot. if(seed==null) { Long uniqueIdCounter = (Long) getStateHelper().get(PropertyKeys.uniqueIdCounter); uniqueIdCounter = (uniqueIdCounter == null) ? 0 : uniqueIdCounter; getStateHelper().put(PropertyKeys.uniqueIdCounter, (uniqueIdCounter+1L)); return bld.append(UIViewRoot.UNIQUE_ID_PREFIX).append(uniqueIdCounter).toString(); } // Optionally, a unique seed value can be supplied by component creators // which should be included in the generated unique id. else { return bld.append(UIViewRoot.UNIQUE_ID_PREFIX).append(seed).toString(); } } /** * * @param context * @return * * @since 2.0 */ @SuppressWarnings("deprecation") |
File | Line |
---|---|
javax/faces/component/_ComponentUtils.java | 415 |
javax/faces/webapp/UIComponentClassicTagBase.java | 963 |
} /** Generate diagnostic output. */ private static void getPathToComponent(UIComponent component, StringBuffer buf) { if (component == null) { return; } StringBuffer intBuf = new StringBuffer(); intBuf.append("[Class: "); intBuf.append(component.getClass().getName()); if (component instanceof UIViewRoot) { intBuf.append(",ViewId: "); intBuf.append(((UIViewRoot)component).getViewId()); } else { intBuf.append(",Id: "); intBuf.append(component.getId()); } intBuf.append("]"); buf.insert(0, intBuf); |
File | Line |
---|---|
javax/faces/component/_ComponentAttributesMap.java | 356 |
javax/faces/component/_ComponentAttributesMap.java | 396 |
if (attribute.getName().equals(key)) { String attributeName = attribute.getName(); boolean isKnownMethod = "action".equals(attributeName) || "actionListener".equals(attributeName) || "validator".equals(attributeName) || "valueChangeListener".equals(attributeName); // <composite:attribute> method-signature attribute is // ValueExpression that must evaluate to String ValueExpression methodSignatureExpression = (ValueExpression) attribute.getValue("method-signature"); String methodSignature = null; if (methodSignatureExpression != null) { // Check if the value expression holds a method signature // Note that it could be null, so in that case we don't have to // do anything methodSignature = (String) methodSignatureExpression.getValue( _component.getFacesContext().getELContext()); } // either the attributeName has to be a knownMethod // or there has to be a method-signature if (isKnownMethod || methodSignature != null) { //In this case it is expecting a ValueExpression return attribute.getValue("default"); } else { value = attribute.getValue("default"); |
File | Line |
---|---|
javax/faces/component/html/_HtmlBody.java | 54 |
javax/faces/component/html/_HtmlHead.java | 52 |
public abstract String getLang(); /** * * @since 2.1.0 * @return */ @JSFProperty public abstract String getXmlns(); @JSFExclude @JSFProperty(tagExcluded=true) @Override public Converter getConverter() { return super.getConverter(); } @JSFExclude @JSFProperty(tagExcluded=true) @Override public Object getValue() { return super.getValue(); } @JSFExclude @JSFProperty(tagExcluded=true) @Override public String getId() { return super.getId(); } @JSFExclude @JSFProperty(tagExcluded=true) @Override public boolean isRendered() { return super.isRendered(); } } |
File | Line |
---|---|
javax/faces/component/UIComponentBase.java | 1699 |
javax/faces/webapp/UIComponentClassicTagBase.java | 966 |
private static void getPathToComponent(UIComponent component, StringBuffer buf) { if (component == null) { return; } StringBuffer intBuf = new StringBuffer(); intBuf.append("[Class: "); intBuf.append(component.getClass().getName()); if (component instanceof UIViewRoot) { intBuf.append(",ViewId: "); intBuf.append(((UIViewRoot)component).getViewId()); } else { intBuf.append(",Id: "); intBuf.append(component.getId()); } intBuf.append("]"); buf.insert(0, intBuf); |
File | Line |
---|---|
javax/faces/validator/LengthValidator.java | 154 |
javax/faces/validator/LongRangeValidator.java | 183 |
_minimum = new Long(minimum); clearInitialState(); } public boolean isTransient() { return _transient; } public void setTransient(boolean transientValue) { _transient = transientValue; } // RESTORE & SAVE STATE public Object saveState(FacesContext context) { if (!initialStateMarked()) { Object values[] = new Object[2]; values[0] = _maximum; values[1] = _minimum; return values; } return null; } public void restoreState(FacesContext context, Object state) { if (state != null) { Object values[] = (Object[])state; _maximum = (Long)values[0]; |
File | Line |
---|---|
javax/faces/component/_ExternalSpecifications.java | 49 |
javax/faces/validator/_ExternalSpecifications.java | 53 |
public static boolean isBeanValidationAvailable() { if (beanValidationAvailable == null) { try { try { beanValidationAvailable = (Class.forName("javax.validation.Validation") != null); } catch(ClassNotFoundException e) { beanValidationAvailable = Boolean.FALSE; } if (beanValidationAvailable) { try { // Trial-error approach to check for Bean Validation impl existence. // If any Exception occurs here, we assume that Bean Validation is not available. // The cause may be anything, i.e. NoClassDef, config error... _ValidationUtils.tryBuildDefaultValidatorFactory(); } catch (Throwable t) { log.log(Level.FINE, "Error initializing Bean Validation (could be normal)", t); beanValidationAvailable = false; } } } catch (Throwable t) { log.log(Level.FINE, "Error loading class (could be normal)", t); beanValidationAvailable = false; } |
File | Line |
---|---|
javax/faces/component/_AttachedStateWrapper.java | 27 |
javax/faces/component/behavior/_AttachedStateWrapper.java | 27 |
class _AttachedStateWrapper implements Serializable { private static final long serialVersionUID = 4948301780259917764L; private Class<?> _class; private Object _wrappedStateObject; /** * @param clazz * null means wrappedStateObject is a List of state objects * @param wrappedStateObject */ public _AttachedStateWrapper(Class<?> clazz, Object wrappedStateObject) { if (wrappedStateObject != null && !(wrappedStateObject instanceof Serializable)) { throw new IllegalArgumentException("Attached state for Object of type " + clazz + " (Class " + wrappedStateObject.getClass().getName() + ") is not serializable"); } _class = clazz; _wrappedStateObject = wrappedStateObject; } public Class<?> getClazz() { return _class; } public Object getWrappedStateObject() { return _wrappedStateObject; } } |