01: /* Licensed to the Apache Software Foundation (ASF) under one or more
02: * contributor license agreements. See the NOTICE file distributed with
03: * this work for additional information regarding copyright ownership.
04: * The ASF licenses this file to You under the Apache License, Version 2.0
05: * (the "License"); you may not use this file except in compliance with
06: * the License. You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package java.nio.charset.spi;
18:
19: import java.nio.charset.Charset;
20: import java.util.Iterator;
21:
22: /**
23: * The service provider class for character sets.
24: */
25: public abstract class CharsetProvider {
26:
27: // The permission required to construct a new provider.
28: private static final RuntimePermission CONSTRUCT_PERM = new RuntimePermission(
29: "charsetProvider"); //$NON-NLS-1$
30:
31: /**
32: * Constructor for subclassing with concrete types.
33: *
34: * @throws SecurityException
35: * if there is a security manager installed that does not permit
36: * the runtime permission labeled "charsetProvider".
37: */
38: protected CharsetProvider() {
39: SecurityManager securityManager = System.getSecurityManager();
40: if (securityManager != null)
41: securityManager.checkPermission(CONSTRUCT_PERM);
42: }
43:
44: /**
45: * Answers an iterator over all the available charsets.
46: *
47: * @return the iterator.
48: */
49: public abstract Iterator<Charset> charsets();
50:
51: /**
52: * Answers the named charset.
53: * <p>
54: * If the charset is unavailable the method returns <code>null</code>.
55: *
56: * @param charsetName
57: * the canonical or alias name of a character set.
58: * @return the charset, or <code>null</code> if unavailable.
59: */
60: public abstract Charset charsetForName(String charsetName);
61: }
|