001 /*
002 * JBoss, Home of Professional Open Source.
003 * Copyright 2008, Red Hat Middleware LLC, and individual contributors
004 * as indicated by the @author tags. See the copyright.txt file in the
005 * distribution for a full listing of individual contributors.
006 *
007 * This is free software; you can redistribute it and/or modify it
008 * under the terms of the GNU Lesser General Public License as
009 * published by the Free Software Foundation; either version 2.1 of
010 * the License, or (at your option) any later version.
011 *
012 * This software is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this software; if not, write to the Free
019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021 */
022 package org.jboss.dna.graph.properties;
023
024 import java.io.Serializable;
025 import net.jcip.annotations.Immutable;
026 import org.jboss.dna.common.text.TextEncoder;
027
028 /**
029 * A qualified name consisting of a namespace and a local name.
030 * @author Randall Hauch
031 */
032 @Immutable
033 public interface Name extends Comparable<Name>, Serializable {
034
035 /**
036 * Get the local name part of this qualified name.
037 * @return the local name; never null
038 */
039 String getLocalName();
040
041 /**
042 * Get the URI for the namespace used in this qualified name.
043 * @return the URI; never null but possibly empty
044 */
045 String getNamespaceUri();
046
047 /**
048 * Get the string form of the name. The {@link Path#DEFAULT_ENCODER default encoder} is used to encode characters in the local
049 * name and namespace.
050 * @return the encoded string
051 * @see #getString(TextEncoder)
052 */
053 public String getString();
054
055 /**
056 * Get the encoded string form of the name, using the supplied encoder to encode characters in the local name and namespace.
057 * @param encoder the encoder to use, or null if the {@link Path#DEFAULT_ENCODER default encoder} should be used
058 * @return the encoded string
059 * @see #getString()
060 */
061 public String getString( TextEncoder encoder );
062
063 /**
064 * Get the string form of the name, using the supplied namespace registry to convert the
065 * {@link #getNamespaceUri() namespace URI} to a prefix. The {@link Path#DEFAULT_ENCODER default encoder} is used to encode
066 * characters in each of the path segments.
067 * @param namespaceRegistry the namespace registry that should be used to obtain the prefix for the
068 * {@link Name#getNamespaceUri() namespace URI}
069 * @return the encoded string
070 * @throws IllegalArgumentException if the namespace registry is null
071 * @see #getString(NamespaceRegistry,TextEncoder)
072 */
073 public String getString( NamespaceRegistry namespaceRegistry );
074
075 /**
076 * Get the encoded string form of the name, using the supplied namespace registry to convert the
077 * {@link #getNamespaceUri() namespace URI} to a prefix.
078 * @param namespaceRegistry the namespace registry that should be used to obtain the prefix for the
079 * {@link Name#getNamespaceUri() namespace URI}
080 * @param encoder the encoder to use, or null if the {@link Path#DEFAULT_ENCODER default encoder} should be used
081 * @return the encoded string
082 * @throws IllegalArgumentException if the namespace registry is null
083 * @see #getString(NamespaceRegistry)
084 */
085 public String getString( NamespaceRegistry namespaceRegistry, TextEncoder encoder );
086 }