001: /*
002: * (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions
007: * are met:
008: * 1. Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: * 2. Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in the
012: * documentation and/or other materials provided with the distribution.
013: * 3. The name of the author may not be used to endorse or promote products
014: * derived from this software without specific prior written permission.
015:
016: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
017: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
018: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
019: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
020: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
021: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
022: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
023: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
024: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
025: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
026:
027: * * $Id: ARPString.java,v 1.6 2008/01/02 12:09:06 andy_seaborne Exp $
028:
029: AUTHOR: Jeremy J. Carroll
030: */
031: /*
032: * StringToken.java
033: *
034: * Created on June 22, 2001, 9:44 AM
035: */
036:
037: package com.hp.hpl.jena.rdf.arp.impl;
038:
039: import org.xml.sax.SAXParseException;
040:
041: import com.hp.hpl.jena.rdf.arp.ALiteral;
042: import com.hp.hpl.jena.rdf.arp.states.Frame;
043:
044: /**
045: *
046: * @author jjc
047: */
048: public class ARPString extends TaintImpl implements ALiteral {
049:
050: final static String RDFXMLLiteral = "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral";
051:
052: /** Creates new StringToken */
053: public ARPString(Frame f, String value, String parseType)
054: throws SAXParseException {
055: f.checkString(this , value);
056: this .value = value;
057: this .lang = "";
058: this .isWellFormedXML = true;
059: this .parseType = parseType;
060: }
061:
062: public ARPString(Frame f, String value, AbsXMLContext forXMLLang)
063: throws SAXParseException {
064: f.checkString(this , value);
065: this .value = value;
066: this .lang = forXMLLang.getLang(this );
067: this .isWellFormedXML = false;
068: }
069:
070: private String value;
071: private String lang;
072: private boolean isWellFormedXML;
073: private String parseType;
074:
075: public String toString() {
076: return value;
077: }
078:
079: // public ARPString concatenate(ARPString s2) {
080: // if (lang.equals(s2.lang)) {
081: // return new ARPString(value+s2.value,lang);
082: // }
083: // throw
084: // new IllegalArgumentException("ARPStrings can only be concatenated if they have the same xml:lang attribute");
085: // }
086: // ARPString quickConcatenate(ARPString s2) {
087: // return new ARPString(value+s2.value,s2.lang);
088: // }
089:
090: public boolean isWellFormedXML() {
091: return this .isWellFormedXML;
092: }
093:
094: /**
095: * @deprecated
096: */
097: public String getParseType() {
098: return parseType;
099: }
100:
101: public String getLang() {
102: return lang;
103: }
104:
105: public String getDatatypeURI() {
106: return isWellFormedXML ? RDFXMLLiteral : null;
107: }
108:
109: }
|