/** * Overrides clone. * * @return a clone of this instance. * @stable ICU 3.0 */ public Object clone() { MessageFormat fmt = new MessageFormat((java.text.MessageFormat)messageFormat.clone()); fmt.savedPattern = savedPattern; return fmt; }
/** * Overrides clone. * * @return a clone of this instance. * @stable ICU 3.0 */ public Object clone() { MessageFormat fmt = new MessageFormat((java.text.MessageFormat)messageFormat.clone()); fmt.savedPattern = savedPattern; return fmt; }
/** * Builds a filter of the form <email-attr>=<<code>emailAddr</code>> */ public String getFindUserByEmailFilter(String emailAddr) { String emailAttr = attributeMappings.get(AttributeMappingConstants.EMAIL_ATTR_MAPPING_KEY); MessageFormat valueFormat = valueMappings.get(AttributeMappingConstants.EMAIL_ATTR_MAPPING_KEY); if (valueFormat == null) { return emailAttr + "=" + escapeSearchFilterTerm(emailAddr); } else { valueFormat = (MessageFormat) valueFormat.clone(); return emailAttr + "=" + escapeSearchFilterTerm(valueFormat.format(new Object[]{emailAddr})); } }
/** * Builds a filter of the form <email-attr>=<<code>emailAddr</code>> */ public String getFindUserByEmailFilter(String emailAddr) { String emailAttr = attributeMappings.get(AttributeMappingConstants.EMAIL_ATTR_MAPPING_KEY); MessageFormat valueFormat = valueMappings.get(AttributeMappingConstants.EMAIL_ATTR_MAPPING_KEY); if (valueFormat == null) { return emailAttr + "=" + escapeSearchFilterTerm(emailAddr); } else { valueFormat = (MessageFormat) valueFormat.clone(); return emailAttr + "=" + escapeSearchFilterTerm(valueFormat.format(new Object[]{emailAddr})); } }
/** * Builds a filter of the form <login-attr>=<<code>eid</code>> */ public String getFindUserByEidFilter(String eid) { String eidAttr = attributeMappings.get(AttributeMappingConstants.LOGIN_ATTR_MAPPING_KEY); MessageFormat valueFormat = valueMappings.get(AttributeMappingConstants.LOGIN_ATTR_MAPPING_KEY); if (valueFormat == null) { return eidAttr + "=" + escapeSearchFilterTerm(eid); } else { valueFormat = (MessageFormat) valueFormat.clone(); return eidAttr + "=" + escapeSearchFilterTerm(valueFormat.format(new Object[]{eid})); } }
/** * Builds a filter of the form <login-attr>=<<code>eid</code>> */ public String getFindUserByEidFilter(String eid) { String eidAttr = attributeMappings.get(AttributeMappingConstants.LOGIN_ATTR_MAPPING_KEY); MessageFormat valueFormat = valueMappings.get(AttributeMappingConstants.LOGIN_ATTR_MAPPING_KEY); if (valueFormat == null) { return eidAttr + "=" + escapeSearchFilterTerm(eid); } else { valueFormat = (MessageFormat) valueFormat.clone(); return eidAttr + "=" + escapeSearchFilterTerm(valueFormat.format(new Object[]{eid})); } }
public static void main(String[] args) { Object[] testArgs = {new Long(3), "MyDisk"}; MessageFormat form = new MessageFormat("The disk \"{1}\" contains {0} file(s)."); MessageFormat form2 = (MessageFormat) form.clone(); System.out.println(form2.format(testArgs)); }
MessageFormat format = valueMappings.get(logicalAttrName); if (format != null && attrValue != null) { format = (MessageFormat)format.clone(); if ( log.isDebugEnabled() ) { log.debug("mapLdapAttributeOntoUserData(): value mapper [attrValue = " +
MessageFormat format = valueMappings.get(logicalAttrName); if (format != null && attrValue != null) { format = (MessageFormat)format.clone(); log.debug("mapLdapAttributeOntoUserData(): value mapper [attrValue = {}; format={}]", attrValue, format.toString()); attrValue = (String)(format.parse(attrValue, new ParsePosition(0))[0]);
@Override protected void accept(ParameterVisitor visitor, Object value) { // Special cases which MessageFormat treats specially (oddly Calendar is not a special case). if (FormatType.INTEGRAL.canFormat(value)) { visitor.visit(value, FormatChar.DECIMAL, WITH_GROUPING); } else if (FormatType.FLOAT.canFormat(value)) { // Technically floating point formatting via {0} differs from "%,f", but as "%,f" results in // more precision it seems better to mimic "%,f" rather than discard both precision and type // information by calling visitPreformatted(). visitor.visit(value, FormatChar.FLOAT, WITH_GROUPING); } else if (value instanceof Date) { // MessageFormat is not thread safe, so we always clone(). String formatted = ((MessageFormat) prototypeMessageFormatter.clone()) .format(new Object[] {value}, new StringBuffer(), null /* field position */) .toString(); visitor.visitPreformatted(value, formatted); } else if (value instanceof Calendar) { visitor.visitDateTime(value, DateTimeFormat.DATETIME_FULL, getFormatOptions()); } else { visitor.visit(value, FormatChar.STRING, getFormatOptions()); } }