1 16 package org.apache.axis.types; 17 18 19 import org.apache.axis.utils.Messages; 20 import org.apache.axis.utils.XMLChar; 21 22 31 public class NCName extends Name { 32 33 public NCName() { 34 super(); 35 } 36 37 41 public NCName(String stValue) throws IllegalArgumentException { 42 try { 43 setValue(stValue); 44 } 45 catch (IllegalArgumentException e) { 46 throw new IllegalArgumentException ( 48 Messages.getMessage("badNCNameType00") + "data=[" + 49 stValue + "]"); 50 } 51 } 52 53 59 public void setValue(String stValue) throws IllegalArgumentException { 60 if (NCName.isValid(stValue) == false) 61 throw new IllegalArgumentException ( 62 Messages.getMessage("badNCNameType00") + 63 " data=[" + stValue + "]"); 64 m_value = stValue; 65 } 66 67 74 public static boolean isValid(String stValue) { 75 int scan; 76 boolean bValid = true; 77 78 for (scan=0; scan < stValue.length(); scan++) { 79 if (scan == 0) 80 bValid = XMLChar.isNCNameStart(stValue.charAt(scan)); 81 else 82 bValid = XMLChar.isNCName(stValue.charAt(scan)); 83 if (bValid == false) 84 break; 85 } 86 return bValid; 87 } 88 } 89 | Popular Tags |