Example usage for java.text MessageFormat clone

List of usage examples for java.text MessageFormat clone

Introduction

In this page you can find the example usage for java.text MessageFormat clone.

Prototype

public Object clone() 

Source Link

Document

Creates and returns a copy of this object.

Usage

From source file:edu.amc.sakai.user.SimpleLdapAttributeMapper.java

/**
 * A delegate of {@link #mapLdapAttributeOntoUserData(LDAPAttribute, LdapUserData, Collection)}
 * that allows for discrete handling of each logical attribute name associated with
 * the given {@link LDAPAttribute}/*from  www  .j a  v a  2 s  .  co m*/
 * 
 * @param attribute
 * @param userData
 * @param logicalAttrName
 */
protected void mapLdapAttributeOntoUserData(LDAPAttribute attribute, LdapUserData userData,
        String logicalAttrName) {

    String attrValue = attribute.getStringValue();
    MessageFormat format = valueMappings.get(logicalAttrName);
    if (format != null && attrValue != null) {
        format = (MessageFormat) format.clone();
        if (M_log.isDebugEnabled()) {
            M_log.debug("mapLdapAttributeOntoUserData(): value mapper [attrValue = " + attrValue + "; format="
                    + format.toString() + "]");
        }
        attrValue = (String) (format.parse(attrValue, new ParsePosition(0))[0]);
    }

    if (M_log.isDebugEnabled()) {
        M_log.debug("mapLdapAttributeOntoUserData() preparing to map: [logical attr name = " + logicalAttrName
                + "][physical attr name = " + attribute.getName() + "][value = " + attrValue + "]");
    }

    if (logicalAttrName.equals(AttributeMappingConstants.LOGIN_ATTR_MAPPING_KEY)) {
        if (M_log.isDebugEnabled()) {
            M_log.debug("mapLdapAttributeOntoUserData() mapping attribute to User.eid: "
                    + "[logical attr name = " + logicalAttrName + "][physical attr name = "
                    + attribute.getName() + "][value = " + attrValue + "]");
        }
        userData.setEid(attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.FIRST_NAME_ATTR_MAPPING_KEY)) {
        if (M_log.isDebugEnabled()) {
            M_log.debug("mapLdapAttributeOntoUserData() mapping attribute to User.firstName: "
                    + "[logical attr name = " + logicalAttrName + "][physical attr name = "
                    + attribute.getName() + "][value = " + attrValue + "]");
        }
        userData.setFirstName(attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.PREFERRED_FIRST_NAME_ATTR_MAPPING_KEY)) {
        if (M_log.isDebugEnabled()) {
            M_log.debug("mapLdapAttributeOntoUserData() mapping attribute to User.firstNamePreferred: "
                    + "[logical attr name = " + logicalAttrName + "][physical attr name = "
                    + attribute.getName() + "][value = " + attrValue + "]");
        }
        userData.setPreferredFirstName(attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.LAST_NAME_ATTR_MAPPING_KEY)) {
        if (M_log.isDebugEnabled()) {
            M_log.debug("mapLdapAttributeOntoUserData() mapping attribute to User.lastName: "
                    + "[logical attr name = " + logicalAttrName + "][physical attr name = "
                    + attribute.getName() + "][value = " + attrValue + "]");
        }
        userData.setLastName(attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.EMAIL_ATTR_MAPPING_KEY)) {
        if (M_log.isDebugEnabled()) {
            M_log.debug("mapLdapAttributeOntoUserData() mapping attribute to User.email: "
                    + "[logical attr name = " + logicalAttrName + "][physical attr name = "
                    + attribute.getName() + "][value = " + attrValue + "]");
        }
        userData.setEmail(attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.DISPLAY_ID_ATTR_MAPPING_KEY)) {
        if (M_log.isDebugEnabled()) {
            M_log.debug("mapLdapAttributeOntoUserData() mapping attribute to User display Id: "
                    + "[logical attr name = " + logicalAttrName + "][physical attr name = "
                    + attribute.getName() + "][value = " + attrValue + "]");
        }
        userData.setProperty(JLDAPDirectoryProvider.DISPLAY_ID_PROPERTY, attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.DISPLAY_NAME_ATTR_MAPPING_KEY)) {
        if (M_log.isDebugEnabled()) {
            M_log.debug("mapLdapAttributeOntoUserData() mapping attribute to User display name: "
                    + "[logical attr name = " + logicalAttrName + "][physical attr name = "
                    + attribute.getName() + "][value = " + attrValue + "]");
        }
        userData.setProperty(JLDAPDirectoryProvider.DISPLAY_NAME_PROPERTY, attrValue);
    } else {
        if (M_log.isDebugEnabled()) {
            M_log.debug("mapLdapAttributeOntoUserData() mapping attribute to a User property: "
                    + "[logical attr name (and property name) = " + logicalAttrName + "][physical attr name = "
                    + attribute.getName() + "][value = " + attrValue + "]");
        }
        userData.setProperty(logicalAttrName, attrValue);
    }

}

From source file:edu.amc.sakai.user.SimpleLdapAttributeMapper.java

/**
 * Builds a filter of the form &lt;login-attr&gt;=&lt;<code>eid</code>&gt;
 *///from  w  w w.  j a va  2  s.  co m
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 }));
    }
}

From source file:edu.amc.sakai.user.SimpleLdapAttributeMapper.java

/**
 * Builds a filter of the form &lt;email-attr&gt;=&lt;<code>emailAddr</code>&gt;
 *//*  w  ww.  j  a  v a  2s  . com*/
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 }));
    }
}

From source file:org.sakaiproject.unboundid.SimpleLdapAttributeMapper.java

/**
 * A delegate of {@link #mapLdapAttributeOntoUserData(LDAPAttribute, LdapUserData, Collection)}
 * that allows for discrete handling of each logical attribute name associated with
 * the given {@link LDAPAttribute}/*from w  w w .  j a  va  2 s  .c o  m*/
 * 
 * @param attribute
 * @param userData
 * @param logicalAttrName
 */
protected void mapLdapAttributeOntoUserData(LDAPAttribute attribute, LdapUserData userData,
        String logicalAttrName) {

    Attribute unboundidAttribute = attribute.toAttribute();
    String attrValue = unboundidAttribute.getValue();
    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]);
    }

    log.debug(
            "mapLdapAttributeOntoUserData() preparing to map: [logical attr name = {}][physical attr name = {}][value = {}]",
            logicalAttrName, attribute.getName(), attrValue);

    if (logicalAttrName.equals(AttributeMappingConstants.LOGIN_ATTR_MAPPING_KEY)) {
        log.debug(
                "mapLdapAttributeOntoUserData() mapping attribute to User.eid: [logical attr name = {}][physical attr name = {}][value = {}]",
                logicalAttrName, attribute.getName(), attrValue);
        userData.setEid(attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.FIRST_NAME_ATTR_MAPPING_KEY)) {
        log.debug(
                "mapLdapAttributeOntoUserData() mapping attribute to User.firstName: [logical attr name = {}][physical attr name = [}][value = {}]",
                logicalAttrName, attribute.getName(), attrValue);
        userData.setFirstName(attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.PREFERRED_FIRST_NAME_ATTR_MAPPING_KEY)) {
        log.debug(
                "mapLdapAttributeOntoUserData() mapping attribute to User.firstNamePreferred: logical attr name = {}][physical attr name = {}][value = {}]",
                logicalAttrName, attribute.getName(), attrValue);
        userData.setPreferredFirstName(attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.LAST_NAME_ATTR_MAPPING_KEY)) {
        log.debug(
                "mapLdapAttributeOntoUserData() mapping attribute to User.lastName: [logical attr name = {}][physical attr name = {}][value = {}]",
                logicalAttrName, attribute.getName(), attrValue);
        userData.setLastName(attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.EMAIL_ATTR_MAPPING_KEY)) {
        log.debug(
                "mapLdapAttributeOntoUserData() mapping attribute to User.email: [logical attr name = {}][physical attr name = {}][value = {}]",
                logicalAttrName, attribute.getName(), attrValue);
        userData.setEmail(attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.DISPLAY_ID_ATTR_MAPPING_KEY)) {
        log.debug(
                "mapLdapAttributeOntoUserData() mapping attribute to User display Id: logical attr name = {}][physical attr name = {}][value = {}]",
                logicalAttrName, attribute.getName(), attrValue);
        userData.setProperty(UnboundidDirectoryProvider.DISPLAY_ID_PROPERTY, attrValue);
    } else if (logicalAttrName.equals(AttributeMappingConstants.DISPLAY_NAME_ATTR_MAPPING_KEY)) {
        log.debug(
                "mapLdapAttributeOntoUserData() mapping attribute to User display name: [logical attr name = {}][physical attr name = {}][value = {}]",
                logicalAttrName, attribute.getName(), attrValue);
        userData.setProperty(UnboundidDirectoryProvider.DISPLAY_NAME_PROPERTY, attrValue);
    } else {
        log.debug(
                "mapLdapAttributeOntoUserData() mapping attribute to a User property: [logical attr name (and property name) = {}][physical attr name = {}][value = {}]",
                logicalAttrName, attribute.getName(), attrValue);
        userData.setProperty(logicalAttrName, attrValue);
    }

}