1 19 package org.netbeans.modules.xslt.model.impl; 20 21 import javax.xml.namespace.QName ; 22 23 import org.netbeans.modules.xslt.model.AttributeValueTemplate; 24 25 26 30 class AttributeValueTemplateImpl implements AttributeValueTemplate { 31 32 AttributeValueTemplateImpl( XslComponentImpl parent, String value ) { 33 assert value!=null; 34 assert parent!=null; 35 36 myValue = value; 37 myParent = parent; 38 int begin = myValue.indexOf( "{" ); 39 if ( begin > -1 ) { 40 isTemplate = myValue.indexOf( "}" ) > begin; 41 } 42 else { 43 isTemplate = false; 44 } 45 } 46 47 AttributeValueTemplateImpl( QName qName ) { 48 myQName = qName; 49 isTemplate = false; 50 String localPart = qName.getLocalPart(); 51 String prefix = qName.getPrefix(); 53 if ( prefix == null || prefix.length() == 0) { 54 myValue = localPart; 55 } 56 else { 57 myValue = prefix + ":" +localPart; 58 } 59 } 60 61 64 public QName getQName() { 65 if ( myQName != null ) { 66 return myQName; 67 } 68 else { 69 return QNameBuilder.createQName( getParent(), toString() ); 70 } 71 } 72 73 76 public boolean isTemplate() { 77 return isTemplate; 78 } 79 80 83 @Override 84 public String toString() 85 { 86 return myValue; 87 } 88 89 public static AttributeValueTemplateImpl creatAttributeValueTemplate( 90 XslComponentImpl parent, XslAttributes attr ) 91 { 92 String str = parent.getAttribute( attr ); 93 return creatAttributeValueTemplate( parent , str ); 94 } 95 96 public static AttributeValueTemplateImpl creatAttributeValueTemplate( 97 XslComponentImpl parent, String value ) 98 { 99 if ( value == null ) { 100 return null; 101 } 102 return new AttributeValueTemplateImpl( parent , value ); 103 } 104 105 public static AttributeValueTemplateImpl creatAttributeValueTemplate( 106 QName qName ) 107 { 108 return new AttributeValueTemplateImpl( qName ); 109 } 110 111 private XslComponentImpl getParent() { 112 return myParent; 113 } 114 115 private XslComponentImpl myParent; 116 117 private String myValue; 118 119 private boolean isTemplate; 120 121 private QName myQName; 122 123 } 124 | Popular Tags |