All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.fedora.common.rdf.RDFName Maven / Gradle / Ivy

/*
 * -----------------------------------------------------------------------------
 *
 * 

License and Copyright: The contents of this file are subject to the * Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of * the License at * http://www.fedora-commons.org/licenses.

* *

Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License.

* *

The entire file consists of original code.

*

Copyright © 2008 Fedora Commons, Inc.
*

Copyright © 2002-2007 The Rector and Visitors of the University of * Virginia and Cornell University
* All rights reserved.

* * ----------------------------------------------------------------------------- */ package fedora.common.rdf; import java.net.*; import org.jrdf.graph.*; /** * A URIReference from a known namespace. * */ public class RDFName implements URIReference { private static final long serialVersionUID = 1L; public RDFNamespace namespace; public String localName; public String uri; private URI m_uri; public RDFName(RDFNamespace namespace, String localName) { try { this.namespace = namespace; this.localName = localName; this.uri = namespace.uri + localName; m_uri = new URI(this.uri); } catch (URISyntaxException e) { throw new RuntimeException("Bad URI Syntax", e); } } /** * Does the given string loosely match this name? * * Either: 1) It matches localName (case insensitive) * 2) It matches uri (case sensitive) * if (firstLocalNameChar == true): * 3) It is one character long, and that character * matches the first character of localName (case insensitive) */ public boolean looselyMatches(String in, boolean tryFirstLocalNameChar) { if (in == null || in.length() == 0) return false; if (in.equalsIgnoreCase(this.localName)) return true; if (in.equals(uri)) return true; if (tryFirstLocalNameChar && in.length() == 1 && in.toUpperCase().charAt(0) == localName.toUpperCase().charAt(0)) return true; return false; } // // Implementation of the URIReference interface // public void accept(TypedNodeVisitor visitor) { visitor.visitURIReference(this); } public URI getURI() { return m_uri; } @Override public String toString() { return uri; } public String stringValue() { return toString(); } public String getLocalName() { return localName; } public String getNamespace() { return namespace.toString(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy