View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors. 
8    *
9    * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10   * is licensed to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   *
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.graph.property;
25  
26  import net.jcip.annotations.Immutable;
27  import org.modeshape.common.text.TextEncoder;
28  import org.modeshape.graph.property.Path.Segment;
29  
30  /**
31   * An interface defining methods to obtain a "readable" string representation.
32   */
33  @Immutable
34  public interface Readable {
35  
36      /**
37       * Get the string form of the object. A {@link Path#DEFAULT_ENCODER default encoder} is used to encode characters.
38       * 
39       * @return the encoded string
40       * @see #getString(TextEncoder)
41       */
42      public String getString();
43  
44      /**
45       * Get the encoded string form of the object, using the supplied encoder to encode characters.
46       * 
47       * @param encoder the encoder to use, or null if the {@link Path#DEFAULT_ENCODER default encoder} should be used
48       * @return the encoded string
49       * @see #getString()
50       */
51      public String getString( TextEncoder encoder );
52  
53      /**
54       * Get the string form of the object, using the supplied namespace registry to convert any namespace URIs to prefixes. A
55       * {@link Path#DEFAULT_ENCODER default encoder} is used to encode characters.
56       * 
57       * @param namespaceRegistry the namespace registry that should be used to obtain the prefix for any namespace URIs
58       * @return the encoded string
59       * @throws IllegalArgumentException if the namespace registry is null
60       * @see #getString(NamespaceRegistry,TextEncoder)
61       */
62      public String getString( NamespaceRegistry namespaceRegistry );
63  
64      /**
65       * Get the encoded string form of the object, using the supplied namespace registry to convert the any namespace URIs to
66       * prefixes.
67       * 
68       * @param namespaceRegistry the namespace registry that should be used to obtain the prefix for the namespace URIs
69       * @param encoder the encoder to use, or null if the {@link Path#DEFAULT_ENCODER default encoder} should be used
70       * @return the encoded string
71       * @throws IllegalArgumentException if the namespace registry is null
72       * @see #getString(NamespaceRegistry)
73       */
74      public String getString( NamespaceRegistry namespaceRegistry,
75                               TextEncoder encoder );
76  
77      /**
78       * Get the encoded string form of the object, using the supplied namespace registry to convert the names' namespace URIs to
79       * prefixes and the supplied encoder to encode characters, and using the second delimiter to encode (or convert) the delimiter
80       * used between the namespace prefix and the local part of any names.
81       * 
82       * @param namespaceRegistry the namespace registry that should be used to obtain the prefix for the namespace URIs in the
83       *        segment {@link Segment#getName() names}
84       * @param encoder the encoder to use for encoding the local part and namespace prefix of any names, or null if the
85       *        {@link Path#DEFAULT_ENCODER default encoder} should be used
86       * @param delimiterEncoder the encoder to use for encoding the delimiter between the local part and namespace prefix of any
87       *        names, or null if the standard delimiter should be used
88       * @return the encoded string
89       * @see #getString(NamespaceRegistry)
90       * @see #getString(NamespaceRegistry, TextEncoder)
91       */
92      public String getString( NamespaceRegistry namespaceRegistry,
93                               TextEncoder encoder,
94                               TextEncoder delimiterEncoder );
95  }