/** * Get the value of the currently selected property. * @return Object value */ @Override public Object getBaseValue() { if (baseValue == UNINITIALIZED) { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { return null; } baseValue = ValueUtils.getValue(getBean(), pd); } return baseValue; }
/** * Get the value of the currently selected property. * @return Object value */ @Override public Object getBaseValue() { if (baseValue == UNINITIALIZED) { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { return null; } baseValue = ValueUtils.getValue(getBean(), pd); } return baseValue; }
/** * If index == WHOLE_COLLECTION, change the value of the property, otherwise * change the value of the index'th element of the collection * represented by the property. * @param value value to set */ @Override public void setValue(Object value) { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { throw new JXPathInvalidAccessException( "Cannot set property: " + asPath() + " - no such property"); } if (index == WHOLE_COLLECTION) { ValueUtils.setValue(getBean(), pd, value); } else { ValueUtils.setValue(getBean(), pd, index, value); } this.value = value; }
/** * If index == WHOLE_COLLECTION, change the value of the property, otherwise * change the value of the index'th element of the collection * represented by the property. * @param value value to set */ @Override public void setValue(Object value) { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { throw new JXPathInvalidAccessException( "Cannot set property: " + asPath() + " - no such property"); } if (index == WHOLE_COLLECTION) { ValueUtils.setValue(getBean(), pd, value); } else { ValueUtils.setValue(getBean(), pd, index, value); } this.value = value; }
/** * If the property contains a collection, then the length of that * collection, otherwise - 1. * @return int length */ @Override public int getLength() { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { return 1; } if( pd.isMany() ) { return ((List<?>)getBean().eGet(pd)).size(); } // if (pd instanceof IndexedPropertyDescriptor) { // return ValueUtils.getIndexedPropertyLength( // getBean(), // (IndexedPropertyDescriptor) pd); // } // // int hint = ValueUtils.getCollectionHint(pd.getPropertyType()); // if (hint == -1) { // return 1; // } return ValueUtils.getLength(getBaseValue()); }
/** * If the property contains a collection, then the length of that * collection, otherwise - 1. * @return int length */ @Override public int getLength() { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { return 1; } if( pd.isMany() ) { return ((List<?>)getBean().eGet(pd)).size(); } // if (pd instanceof IndexedPropertyDescriptor) { // return ValueUtils.getIndexedPropertyLength( // getBean(), // (IndexedPropertyDescriptor) pd); // } // // int hint = ValueUtils.getCollectionHint(pd.getPropertyType()); // if (hint == -1) { // return 1; // } return ValueUtils.getLength(getBaseValue()); }
/** * If index == WHOLE_COLLECTION, the value of the property, otherwise * the value of the index'th element of the collection represented by the * property. If the property is not a collection, index should be zero * and the value will be the property itself. * @return Object */ @Override public Object getImmediateNode() { if (value == UNINITIALIZED) { if (index == WHOLE_COLLECTION) { value = ValueUtils.getValue(getBaseValue()); } else { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { value = null; } else { value = ValueUtils.getValue(getBean(), pd, index); } } } return value; }
/** * If index == WHOLE_COLLECTION, the value of the property, otherwise * the value of the index'th element of the collection represented by the * property. If the property is not a collection, index should be zero * and the value will be the property itself. * @return Object */ @Override public Object getImmediateNode() { if (value == UNINITIALIZED) { if (index == WHOLE_COLLECTION) { value = ValueUtils.getValue(getBaseValue()); } else { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { value = null; } else { value = ValueUtils.getValue(getBean(), pd, index); } } } return value; }
@Override public void remove() { if (index == WHOLE_COLLECTION) { setValue(null); } else if (isCollection()) { Object o = getBaseValue(); Object collection = ValueUtils.remove(getBaseValue(), index); if (collection != o) { ValueUtils.setValue(getBean(), getPropertyDescriptor(), collection); } } else if (index == 0) { index = WHOLE_COLLECTION; setValue(null); } }
@Override public void remove() { if (index == WHOLE_COLLECTION) { setValue(null); } else if (isCollection()) { Object o = getBaseValue(); Object collection = ValueUtils.remove(getBaseValue(), index); if (collection != o) { ValueUtils.setValue(getBean(), getPropertyDescriptor(), collection); } } else if (index == 0) { index = WHOLE_COLLECTION; setValue(null); } }