protected NakedObjectMemberAbstract( final String id, final Identified facetHolder, final MemberType memberType, final RuntimeContext runtimeContext) { if (id == null) { throw new IllegalArgumentException("Name must always be set"); } this.id = id; this.defaultName = NameConvertorUtils.naturalName(id); this.facetHolder = facetHolder; this.memberType = memberType; this.runtimeContext = runtimeContext; }
private NakedObjectMemberPeer getMemberWithName(final String name) { final String searchName = NameConvertorUtils.simpleName(name); for (int i = 0; i < members.length; i++) { final NakedObjectMemberPeer member = members[i]; if (member != null) { final String testName = NameConvertorUtils.simpleName(member.getIdentifier().getMemberName()); if (testName.equals(searchName)) { members[i] = null; return member; } } } return null; }
private void createPropertyPeersFromAccessors(final List<Method> propertyAccessors, final List<NakedObjectAssociationPeer> associationPeerListToAppendto) throws ReflectionException { for (final Method accessorMethod : propertyAccessors) { LOG.debug(" identified 1-1 association method " + accessorMethod); final String capitalizedName = NameUtils.javaBaseName(accessorMethod.getName()); final String beanName = Introspector.decapitalize(capitalizedName); final Class<?> returnType = accessorMethod.getReturnType(); // skip if class strategy says so. if (getClassSubstitutor().getClass(returnType) == null) { continue; } if (LOG.isDebugEnabled()) { LOG.debug("one-to-one association " + capitalizedName + " ->" + accessorMethod); } final Identifier identifier = Identifier.propertyOrCollectionIdentifier(className, beanName); // create a 1:1 association peer final JavaOneToOneAssociationPeer associationPeer = new JavaOneToOneAssociationPeer(identifier, returnType, getSpecificationLoader()); // process facets for the 1:1 association getFacetProcessor().process(type, accessorMethod, new JavaIntrospectorMethodRemover(), associationPeer, NakedObjectFeatureType.PROPERTY); associationPeerListToAppendto.add(associationPeer); } }
@Override public boolean process(Class<?> cls, final Method actionMethod, final MethodRemover methodRemover, final FacetHolder action) { final String capitalizedName = NameUtils.capitalizeName(actionMethod.getName()); final Class<?> returnType = actionMethod.getReturnType(); final Class<?>[] paramTypes = actionMethod.getParameterTypes();
protected NakedObjectMemberAbstract( final String id, final Identified facetHolder, final MemberType memberType, final RuntimeContext runtimeContext) { if (id == null) { throw new IllegalArgumentException("Name must always be set"); } this.id = id; this.defaultName = NameConvertorUtils.naturalName(id); this.facetHolder = facetHolder; this.memberType = memberType; this.runtimeContext = runtimeContext; }
private void createPropertyPeersFromAccessors(final List<Method> propertyAccessors, final List<NakedObjectAssociationPeer> associationPeerListToAppendto) throws ReflectionException { for (final Method accessorMethod : propertyAccessors) { LOG.debug(" identified 1-1 association method " + accessorMethod); final String capitalizedName = NameUtils.javaBaseName(accessorMethod.getName()); final String beanName = Introspector.decapitalize(capitalizedName); final Class<?> returnType = accessorMethod.getReturnType(); // skip if class strategy says so. if (getClassSubstitutor().getClass(returnType) == null) { continue; } if (LOG.isDebugEnabled()) { LOG.debug("one-to-one association " + capitalizedName + " ->" + accessorMethod); } final Identifier identifier = Identifier.propertyOrCollectionIdentifier(className, beanName); // create a 1:1 association peer final JavaOneToOneAssociationPeer associationPeer = new JavaOneToOneAssociationPeer(identifier, returnType, getSpecificationLoader()); // process facets for the 1:1 association getFacetProcessor().process(accessorMethod, new JavaIntrospectorMethodRemover(), associationPeer, NakedObjectFeatureType.PROPERTY); associationPeerListToAppendto.add(associationPeer); } }
private NakedObjectMemberPeer getMemberWithName(final String name) { final String searchName = NameConvertorUtils.simpleName(name); for (int i = 0; i < members.length; i++) { final NakedObjectMemberPeer member = members[i]; if (member != null) { final String testName = NameConvertorUtils.simpleName(member.getIdentifier().getMemberName()); if (testName.equals(searchName)) { members[i] = null; return member; } } } return null; }
public ExceptionMessageContent(final Throwable error) { String fullName = error.getClass().getName(); fullName = fullName.substring(fullName.lastIndexOf('.') + 1); name = NameConvertorUtils.naturalName(fullName); message = error.getMessage(); trace = ExceptionHelper.exceptionTraceAsString(error); if (trace.indexOf("\tat") != -1) { trace = trace.substring(trace.indexOf("\tat")); } if (name == null) { name = ""; } if (message == null) { message = ""; } if (trace == null) { trace = ""; } if (error instanceof NakedObjectApplicationException) { title = "Application Error"; icon = "application-error"; } else if (error instanceof ConcurrencyException) { title = "Concurrency Error"; icon = "concurrency-error"; } else { title = "System Error"; icon = "system-error"; } }
@Override public boolean process(final Method collectionAccessor, final MethodRemover methodRemover, final FacetHolder collection) { final String capitalizedName = NameUtils.javaBaseName(collectionAccessor.getName()); final Class<?> returnType = collectionAccessor.getReturnType(); final Class<?> cls = collectionAccessor.getDeclaringClass(); final List<Facet> facets = new ArrayList<Facet>(); removeMethod(methodRemover, collectionAccessor); facets.add(new PropertyAccessorFacetViaAccessor(collectionAccessor, collection)); final Class<?> addToType = findAndRemoveAddToMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); final Class<?> removeFromType = findAndRemoveRemoveFromMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); final Class<?> collectionType = inferTypeOfIfPossible(facets, collectionAccessor, addToType, removeFromType, collection); findAndRemoveClearMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); findAndRemoveValidateAddToMethod(facets, methodRemover, cls, collectionType, capitalizedName, returnType, collection); findAndRemoveValidateRemoveFromMethod(facets, methodRemover, cls, collectionType, capitalizedName, returnType, collection); findAndRemoveNameMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveDescriptionMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveAlwaysHideMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveProtectMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveHideForSessionMethod(facets, methodRemover, cls, capitalizedName, UserMemento.class, collection); findAndRemoveDisableForSessionMethod(facets, methodRemover, cls, capitalizedName, UserMemento.class, collection); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, collection); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, collection); return FacetUtil.addFacets(facets); }
public NakedObjectSpecificationNoMember( final String className, final RuntimeContext runtimeContext) { super(runtimeContext); this.fullName = className; this.name = NameConvertorUtils.simpleName(className.substring(className.lastIndexOf('.') + 1)); identifier = Identifier.classIdentifier(className); throw new UnexpectedCallException(className); }
/** * Must be called after the checkForXxxPrefix methods. */ private void defaultNamedFacet( final List<Facet> actionFacets, final MethodRemover methodRemover, final String capitalizedName, final FacetHolder action) { String name = removePrefix(capitalizedName, LOCAL_PREFIX); name = removePrefix(name, REMOTE_PREFIX); name = removePrefix(name, DEBUG_PREFIX); name = removePrefix(name, EXPLORATION_PREFIX); name = removePrefix(name, LOCAL_PREFIX); name = removePrefix(name, REMOTE_PREFIX); name = NameConvertorUtils.naturalName(name); actionFacets.add(new NamedFacetInferred(name, action)); }
private void createCollectionPeersFromAccessors(final List<Method> collectionAccessors, final List<NakedObjectAssociationPeer> associationPeerListToAppendto) { for (final Method getMethod : collectionAccessors) { LOG.debug(" identified one-many association method " + getMethod); final String capitalizedName = NameUtils.javaBaseName(getMethod.getName()); final String collectionNameName = Introspector.decapitalize(capitalizedName); final Identifier identifier = Identifier.propertyOrCollectionIdentifier(className(), collectionNameName); // create property and add facets final JavaOneToManyAssociationPeer collection = new JavaOneToManyAssociationPeer(identifier, getSpecificationLoader()); getFacetProcessor().process(type, getMethod, new JavaIntrospectorMethodRemover(), collection, NakedObjectFeatureType.COLLECTION); // figure out what the type is Class<?> elementType = Object.class; final TypeOfFacet typeOfFacet = collection.getFacet(TypeOfFacet.class); if (typeOfFacet != null) { elementType = typeOfFacet.value(); } collection.setElementType(elementType); // skip if class strategy says so. if (getClassSubstitutor().getClass(elementType) == null) { continue; } associationPeerListToAppendto.add(collection); } }
public NakedObjectSpecificationNoMember( final String className, final RuntimeContext runtimeContext) { super(runtimeContext); this.fullName = className; this.name = NameConvertorUtils.simpleName(className.substring(className.lastIndexOf('.') + 1)); identifier = Identifier.classIdentifier(className); throw new UnexpectedCallException(className); }
/** * Must be called after the checkForXxxPrefix methods. */ private void defaultNamedFacet( final List<Facet> actionFacets, final MethodRemover methodRemover, final String capitalizedName, final FacetHolder action) { String name = removePrefix(capitalizedName, LOCAL_PREFIX); name = removePrefix(name, REMOTE_PREFIX); name = removePrefix(name, DEBUG_PREFIX); name = removePrefix(name, EXPLORATION_PREFIX); name = removePrefix(name, LOCAL_PREFIX); name = removePrefix(name, REMOTE_PREFIX); name = NameConvertorUtils.naturalName(name); actionFacets.add(new NamedFacetInferred(name, action)); }
@Override public boolean process( Class<?> cls, final Method collectionAccessor, final MethodRemover methodRemover, final FacetHolder collection) { final String capitalizedName = NameUtils.javaBaseName(collectionAccessor.getName()); final Class<?> returnType = collectionAccessor.getReturnType(); final List<Facet> facets = new ArrayList<Facet>(); removeMethod(methodRemover, collectionAccessor); facets.add(new PropertyAccessorFacetViaAccessor(collectionAccessor, collection)); final Class<?> addToType = findAndRemoveAddToMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); final Class<?> removeFromType = findAndRemoveRemoveFromMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); final Class<?> collectionType = inferTypeOfIfPossible(facets, collectionAccessor, addToType, removeFromType, collection); findAndRemoveClearMethod(facets, methodRemover, cls, collectionAccessor, capitalizedName, collection); findAndRemoveValidateAddToMethod(facets, methodRemover, cls, collectionType, capitalizedName, returnType, collection); findAndRemoveValidateRemoveFromMethod(facets, methodRemover, cls, collectionType, capitalizedName, returnType, collection); findAndRemoveNameMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveDescriptionMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveAlwaysHideMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveProtectMethod(facets, methodRemover, cls, capitalizedName, collection); findAndRemoveHideForSessionMethod(facets, methodRemover, cls, capitalizedName, UserMemento.class, collection); findAndRemoveDisableForSessionMethod(facets, methodRemover, cls, capitalizedName, UserMemento.class, collection); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, collection); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, collection); return FacetUtil.addFacets(facets); }
order[i] = NameConvertorUtils.simpleName(order[i]);
private void createCollectionPeersFromAccessors(final List<Method> collectionAccessors, final List<NakedObjectAssociationPeer> associationPeerListToAppendto) { for (final Method getMethod : collectionAccessors) { LOG.debug(" identified one-many association method " + getMethod); final String capitalizedName = NameUtils.javaBaseName(getMethod.getName()); final String collectionNameName = Introspector.decapitalize(capitalizedName); final Identifier identifier = Identifier.propertyOrCollectionIdentifier(className(), collectionNameName); // create property and add facets final JavaOneToManyAssociationPeer collection = new JavaOneToManyAssociationPeer(identifier, getSpecificationLoader()); getFacetProcessor().process(getMethod, new JavaIntrospectorMethodRemover(), collection, NakedObjectFeatureType.COLLECTION); // figure out what the type is Class<?> elementType = Object.class; final TypeOfFacet typeOfFacet = collection.getFacet(TypeOfFacet.class); if (typeOfFacet != null) { elementType = typeOfFacet.value(); } collection.setElementType(elementType); // skip if class strategy says so. if (getClassSubstitutor().getClass(elementType) == null) { continue; } associationPeerListToAppendto.add(collection); } }
order[i] = NameConvertorUtils.simpleName(order[i]);
@Override public boolean process(final Method getMethod, final MethodRemover methodRemover, final FacetHolder property) { final String capitalizedName = NameUtils.javaBaseName(getMethod.getName()); final Class<?> returnType = getMethod.getReturnType(); final Class<?>[] paramTypes = new Class[] { returnType }; final Class<?> cls = getMethod.getDeclaringClass(); final List<Facet> facets = new ArrayList<Facet>(); removeMethod(methodRemover, getMethod); facets.add(new PropertyAccessorFacetViaAccessor(getMethod, property)); final Method setMethod = findAndRemoveSetterMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveModifyMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); final Method clearMethod = findAndRemoveClearMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); ensureClearViaSetterIfRequired(facets, property, clearMethod, setMethod); findAndRemoveChoicesMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveDefaultMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveValidateMethod(facets, methodRemover, cls, paramTypes, capitalizedName, returnType, property); findAndRemoveNameMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveDescriptionMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveAlwaysHideMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveProtectMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveOptionalMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveHideForSessionMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveDisableForSessionMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, paramTypes, property); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, new Class[] {}, property); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, paramTypes, property); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, new Class[] {}, property); return FacetUtil.addFacets(facets); }
@Override public boolean process(Class<?> cls, final Method getMethod, final MethodRemover methodRemover, final FacetHolder property) { final String capitalizedName = NameUtils.javaBaseName(getMethod.getName()); final Class<?> returnType = getMethod.getReturnType(); final Class<?>[] paramTypes = new Class[] { returnType }; final List<Facet> facets = new ArrayList<Facet>(); removeMethod(methodRemover, getMethod); facets.add(new PropertyAccessorFacetViaAccessor(getMethod, property)); final Method setMethod = findAndRemoveSetterMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveModifyMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); final Method clearMethod = findAndRemoveClearMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); ensureClearViaSetterIfRequired(facets, property, clearMethod, setMethod); findAndRemoveChoicesMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveDefaultMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveValidateMethod(facets, methodRemover, cls, paramTypes, capitalizedName, returnType, property); findAndRemoveNameMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveDescriptionMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveAlwaysHideMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveProtectMethod(facets, methodRemover, cls, capitalizedName, property); findAndRemoveOptionalMethod(facets, methodRemover, cls, capitalizedName, returnType, property); findAndRemoveHideForSessionMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveDisableForSessionMethod(facets, methodRemover, cls, capitalizedName, paramTypes, property); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, paramTypes, property); findAndRemoveHideMethod(facets, methodRemover, cls, OBJECT, capitalizedName, new Class[] {}, property); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, paramTypes, property); findAndRemoveDisableMethod(facets, methodRemover, cls, OBJECT, capitalizedName, new Class[] {}, property); return FacetUtil.addFacets(facets); }