public DynamicTypeImpl clone() { DynamicTypeImpl clone = new DynamicTypeImpl(); super.deepClone(clone); clone.permissions.clear(); for (PermissionImpl perm : permissions) { PermissionImpl permClone = perm.clone(); clone.permissions.add(permClone); } clone.lastChanged = lastChanged; clone.createDate = createDate; clone.name = (MultiLanguageName) name.clone(); clone.key = key; for (AttributeImpl att : clone.getSubEntities()) { ((AttributeImpl) att).setParent(clone); } clone.annotations = new LinkedHashMap<String, ParsedText>(); DynamicTypeParseContext parseContext = new DynamicTypeParseContext(clone); for (Map.Entry<String, ParsedText> entry : annotations.entrySet()) { String annotation = entry.getKey(); ParsedText parsedAnnotation = entry.getValue(); String parsedValue = parsedAnnotation.getExternalRepresentation(parseContext); try { clone.setAnnotation(annotation, parsedValue); } catch (IllegalAnnotationException e) { throw new IllegalStateException("Can't parse annotation back", e); } } return clone; }
public void setKey(String key) { checkWritable(); this.key = key; for (ParsedText text : annotations.values()) { text.updateFormatString(parseContext); } }
public String getAnnotation(String key) { ParsedText parsedAnnotation = annotations.get(key); if (parsedAnnotation != null) { return parsedAnnotation.getExternalRepresentation(parseContext); } else { return null; } }
public void setAnnotation(String key, String annotation) throws IllegalAnnotationException { checkWritable(); if (annotation == null) { annotations.remove(key); return; } ParsedText parsedText = new ParsedText(annotation); parsedText.init(parseContext); annotations.put(key, parsedText); }
public String format(Locale locale, String annotationName) { DynamicTypeImpl type = getType(); ParsedText parsedAnnotation = type.getParsedAnnotation(annotationName); if (parsedAnnotation == null) { return ""; } EvalContext evalContext = type.createEvalContext(locale, annotationName, this); String nameString = parsedAnnotation.formatName(evalContext).trim(); return nameString; }
public String format(Locale locale, String annotationName) { DynamicTypeImpl type = (DynamicTypeImpl) getType(); ParsedText parsedAnnotation = type.getParsedAnnotation(annotationName); if (parsedAnnotation == null) { return ""; } EvalContext evalContext = new EvalContext(locale, annotationName, Collections.singletonList(this)); String nameString = parsedAnnotation.formatName(evalContext).trim(); return nameString; }
public String getName(Locale locale, String keyNameFormat) { DynamicTypeImpl type = (DynamicTypeImpl) getType(); ParsedText parsedAnnotation = type.getParsedAnnotation(keyNameFormat); if (parsedAnnotation == null) { return type.toString(); } if (nameString != null) { if (parsedAnnotation.equals(lastParsedAnnotation)) return nameString; } lastParsedAnnotation = parsedAnnotation; nameString = format(locale, keyNameFormat); return nameString; }
public void setResolver(EntityResolver resolver) { super.setResolver(resolver); for (AttributeImpl child : attributes) { child.setParent(this); } for (ParsedText annotation : annotations.values()) { try { annotation.init(parseContext); } catch (IllegalAnnotationException e) { } } for (PermissionImpl p : permissions) { p.setResolver(resolver); } }
/** * @param attributeImpl * @param key */ public void keyChanged(AttributeImpl attributeImpl, String key) { attributeIndex = null; for (ParsedText text : annotations.values()) { text.updateFormatString(parseContext); } }