/// /// <summary> * set the phone number of this, if this is a valid phone url, "tel:" or /// * "fax:" is prepended, if it is not yet there /// * </summary> /// * <param name="phone"> /// * the phone number string </param> /// * <param name="replaceForBlank"> /// * the replacement char for non-leading blanks , typically "." or /// * null are a good idea </param> /// * <param name="channelType"> /// * the channelType - must be either Fax or Phone </param> /// * <exception cref="IllegalArgumentException"> /// * if phone is not a valid phone number /// * </exception> /// public virtual void setPhoneNumber(string phone, string replaceForBlank, EnumChannelType channelType) { string phoneLocal = phone; if (!EnumChannelType.Fax.Equals(channelType) && !EnumChannelType.Phone.Equals(channelType)) { throw new ArgumentException("illegal channelType: " + channelType); } if (phoneLocal != null) { phoneLocal = phoneLocal.Trim(); } phoneLocal = StringUtil.replaceCharSet(phoneLocal, " ", replaceForBlank, 0); if (phoneLocal == null || !StringUtil.matches(phoneLocal, JDFConstants.REGEXP_PHONE)) { throw new ArgumentException("illegal phone number:" + phoneLocal); } setChannelType(channelType); if (!phoneLocal.ToLower().StartsWith(TEL)) { phoneLocal = TEL + phoneLocal; } setLocator(phoneLocal); }
/// /// <summary> * get the phone number of this, if this is a valid phone address, else null /// * any "tel:" or "fax:" is stripped /// * </summary> /// * <param name="stripNonNumerical"> /// * if true, remove any valid brackets, . / etc. so that a purely /// * numerical code (except for an optional "+" for international) /// * is returned </param> /// * <returns> the phone number </returns> /// public virtual string getPhoneNumber(bool stripNonNumerical) { EnumChannelType channelType = getChannelType(); if (!EnumChannelType.Fax.Equals(channelType) && !EnumChannelType.Phone.Equals(channelType)) { return(null); } string locator = getLocator(); if (!StringUtil.matchesIgnoreCase(locator, JDFConstants.REGEXP_PHONE)) { return(null); } locator = StringUtil.stripPrefix(locator, TEL, true); if (stripNonNumerical) { locator = StringUtil.stripNot(locator, "+0123456789"); } return(locator); }
static JDFAutoComChannel() { atrInfoTable[0] = new AtrInfoTable(AttributeName.CHANNELTYPE, 0x22222222, AttributeInfo.EnumAttributeType.enumeration, EnumChannelType.getEnum(0), null); atrInfoTable[1] = new AtrInfoTable(AttributeName.LOCATOR, 0x22222222, AttributeInfo.EnumAttributeType.string_, null, null); atrInfoTable[2] = new AtrInfoTable(AttributeName.CHANNELTYPEDETAILS, 0x33333311, AttributeInfo.EnumAttributeType.NMTOKEN, null, null); atrInfoTable[3] = new AtrInfoTable(AttributeName.CHANNELUSAGE, 0x33333311, AttributeInfo.EnumAttributeType.NMTOKENS, null, null); }
/// /// <summary> * (9) get attribute ChannelType </summary> /// * <returns> the value of the attribute </returns> /// public virtual EnumChannelType getChannelType() { return(EnumChannelType.getEnum(getAttribute(AttributeName.CHANNELTYPE, null, null))); }
// ************************************************************************ // * Attribute getter / setter // * ************************************************************************ // // --------------------------------------------------------------------- // Methods for Attribute ChannelType // --------------------------------------------------------------------- /// /// <summary> * (5) set attribute ChannelType </summary> /// * <param name="enumVar">: the enumVar to set the attribute to </param> /// public virtual void setChannelType(EnumChannelType enumVar) { setAttribute(AttributeName.CHANNELTYPE, enumVar == null ? null : enumVar.getName(), null); }