001/* 002 * lang-tag 003 * 004 * Copyright 2012-2016, Connect2id Ltd. 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use 007 * this file except in compliance with the License. You may obtain a copy of the 008 * License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software distributed 013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 015 * specific language governing permissions and limitations under the License. 016 */ 017 018package com.nimbusds.langtag; 019 020 021/** 022 * Read-only view of a {@link LangTag Language tag}. 023 */ 024public interface ReadOnlyLangTag { 025 026 027 /** 028 * Gets the language (primary language plus extended language subtags). 029 * 030 * <p>See RFC 5646 section 2.2.1. 031 * 032 * <p>Examples: 033 * 034 * <pre> 035 * en 036 * de 037 * zh-cmn 038 * cmn 039 * </pre> 040 * 041 * @return The language, consisting of the primary and/or extended 042 * language subtags. 043 */ 044 public String getLanguage(); 045 046 047 /** 048 * Gets the primary language. 049 * 050 * <p>See RFC 5646 section 2.2.1. 051 * 052 * @return The primary language, as a two or three-letter ISO 639 code, 053 * in canonical lower case format. 054 */ 055 public String getPrimaryLanguage(); 056 057 058 /** 059 * Gets the extended language subtags. 060 * 061 * <p>See RFC 5646 section 2.2.2. 062 * 063 * @return The extended language subtags, as three-letter ISO 639-3 064 * codes. {@code null} if none. 065 */ 066 public String[] getExtendedLanguageSubtags(); 067 068 069 /** 070 * Gets the script. 071 * 072 * <p>See RFC 5646 section 2.2.3. 073 * 074 * @return The script, as an ISO 15924 code, in canonical title case 075 * format. {@code null} if not defined. 076 */ 077 public String getScript(); 078 079 080 /** 081 * Gets the region. 082 * 083 * <p>See RFC 5646 section 2.2.4. 084 * 085 * @return The region, as a two-letter ISO 3166-1 code or a three-digit 086 * UN M.49 code. {@code null} if not defined. 087 */ 088 public String getRegion(); 089 090 091 /** 092 * Gets the variants. 093 * 094 * <p>See RFC 5646 section 2.2.5. 095 * 096 * @return The variants. {@code null} if not defined. 097 */ 098 public String[] getVariants(); 099 100 101 /** 102 * Gets the extensions. 103 * 104 * <p>See RFC 5646 section 2.2.6. 105 * 106 * @return The extensions. {@code null} if not defined. 107 */ 108 public String[] getExtensions(); 109 110 111 /** 112 * Gets the private use. 113 * 114 * <p>See RFC 5646 section 2.2.7. 115 * 116 * @return The private use. {@code null} if not defined. 117 */ 118 public String getPrivateUse(); 119 120 121 /** 122 * Returns the canonical string representation of this language tag. 123 * 124 * @return The canonical string representation. 125 */ 126 public String toString(); 127}