1 /*------------------------------------------------------------------------------
  2 Name:      EraseKey.java
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 ------------------------------------------------------------------------------*/
  6 package org.xmlBlaster.client.key;
  7 
  8 import org.xmlBlaster.util.Global;
  9 import org.xmlBlaster.util.def.Constants;
 10 import org.xmlBlaster.util.key.QueryKeyData;
 11 import org.xmlBlaster.util.XmlBlasterException;
 12 
 13 /**
 14  * Access to an erase key. 
 15  * <p>
 16  * See QueryKeySaxFactory for a syntax description of the allowed xml structure
 17  * </p>
 18  * @see org.xmlBlaster.util.key.QueryKeySaxFactory
 19  * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/interface.erase.html" target="others">the interface.erase requirement</a>
 20  */
 21 public class EraseKey
 22 {
 23    private final static String ME = "EraseKey";
 24    private final QueryKeyData queryKeyData;
 25 
 26    /**
 27     * Create a key data holder to erase message(s). 
 28     * @param query The query string
 29     *        For example a topic oid like "Hello" or "oid:Hello"
 30     *        or a query like "xpath://key", "domain:CLUSTER")
 31     */
 32    public EraseKey(Global glob, String query) {
 33       this.queryKeyData = new QueryKeyData(glob, query);
 34    }
 35 
 36    /**
 37     * Constructor with given oid.
 38     * @param queryString  The String with e.g. XPath syntax
 39     * @param queryType    The query syntax, e.g. Constants.XPATH
 40     * @param XmlBlasterException for invalid queryType
 41     */
 42    public EraseKey(Global glob, String queryString, String queryType) throws XmlBlasterException {
 43       this.queryKeyData = new QueryKeyData(glob, queryString, queryType);
 44    }
 45 
 46    /**
 47     * Constructor for internal use. 
 48     * @param queryKeyData The struct holding the data
 49     */
 50    public EraseKey(Global glob, QueryKeyData queryKeyData) {
 51       this.queryKeyData = queryKeyData;
 52    }
 53 
 54    public QueryKeyData getData() {
 55       return this.queryKeyData;
 56    }
 57 
 58    /**
 59     * Set the $lt;key oid="...">.
 60     * @param The unique key oid
 61     */
 62    public final void setOid(String oid) {
 63       this.queryKeyData.setOid(oid);
 64    }
 65 
 66    /**
 67     * Access the &lt;key oid="...">.
 68     * @return The unique key oid
 69     */
 70    public final String getOid() {
 71       return this.queryKeyData.getOid();
 72    }
 73 
 74    /**
 75     * Access the query type "XPATH" or "EXACT"
 76     * @return A queryType string or null
 77     */
 78    public String getQueryType() {
 79       return this.queryKeyData.getQueryType();
 80    }
 81 
 82    public boolean isExact() {
 83       return this.queryKeyData.isExact();
 84    }
 85 
 86    public boolean isQuery() {
 87       return this.queryKeyData.isQuery();
 88    }
 89 
 90    public boolean isXPath() {
 91       return this.queryKeyData.isXPath();
 92    }
 93 
 94    /**
 95     * Your XPath query string. 
 96     * @param str Your tags in ASCII XML syntax
 97     */
 98    public void setQueryString(String tags) {
 99       this.queryKeyData.setQueryString(tags);
100    }
101 
102    public String getQueryString() {
103       return this.queryKeyData.getQueryString();
104    }
105 
106    public void setDomain(String domain) {
107       this.queryKeyData.setDomain(domain);
108    }
109 
110    public String getDomain() {
111       return this.queryKeyData.getDomain();
112    }
113 
114    /**
115     * Converts the data in XML ASCII string.
116     * @return An XML ASCII string
117     */
118    public String toString() {
119       return this.queryKeyData.toString();
120    }
121 
122    /**
123     * Converts the data in XML ASCII string.
124     * @return An XML ASCII string
125     */
126    public String toXml() {
127       return this.queryKeyData.toXml();
128    }
129 
130    /**
131     * May be used to integrate your application tags.
132     * @param str Your tags
133     * @return The ASCII XML key containing the key tag and your tags
134     */
135    public String wrap(String str) {
136       this.queryKeyData.setQueryString(str);
137       return this.queryKeyData.toXml();
138    }
139 }


syntax highlighted by Code2HTML, v. 0.9.1