List of usage examples for java.text MessageFormat parse
public Object[] parse(String source, ParsePosition pos)
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}// w ww .ja v a2 s .com * * @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: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}// w w w .j a va2s.com * * @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); } }
From source file:org.talend.core.model.metadata.builder.database.dburl.SupportDBUrlStore.java
public Properties getDBPameterProperties(String connectionStr) { Properties paramProperties = new Properties(); if (connectionStr != null) { String matchSubStr = connectionStr.substring(0, 8); Set<Object> s = PROP.keySet(); Iterator<Object> it = s.iterator(); while (it.hasNext()) { String id = (String) it.next(); String value = PROP.getProperty(id); if (value.contains(matchSubStr)) { paramProperties.setProperty(PluginConstant.DBTYPE_PROPERTY, id); MessageFormat mf = new MessageFormat(value); Object[] parseResult = mf.parse(connectionStr, new ParsePosition(0)); if (parseResult != null) { if (parseResult[0] != null) { paramProperties.setProperty(PluginConstant.HOSTNAME_PROPERTY, (String) parseResult[0]); }/*from ww w . ja v a 2s. co m*/ if (parseResult[1] != null) { paramProperties.setProperty(PluginConstant.PORT_PROPERTY, (String) parseResult[1]); } break; } } } } else { paramProperties.setProperty(PluginConstant.DBTYPE_PROPERTY, ""); paramProperties.setProperty(PluginConstant.HOSTNAME_PROPERTY, ""); paramProperties.setProperty(PluginConstant.PORT_PROPERTY, ""); } return paramProperties; }