1 /* 2 * Copyright (C) 2011 The Libphonenumber Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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 com.google.i18n.phonenumbers; 18 19 import java.io.IOException; 20 import java.io.Writer; 21 import java.util.Formatter; 22 23 /** 24 * Class containing the Apache copyright notice used by code generators. 25 * 26 * @author Philippe Liard 27 */ 28 public class CopyrightNotice { 29 30 private static final String TEXT_OPENING = 31 "/*\n"; 32 33 private static final String TEXT_OPENING_FOR_JAVASCRIPT = 34 "/**\n" + 35 " * @license\n"; 36 37 private static final String TEXT = 38 " * Copyright (C) %d The Libphonenumber Authors\n" + 39 " *\n" + 40 " * Licensed under the Apache License, Version 2.0 (the \"License\");\n" + 41 " * you may not use this file except in compliance with the License.\n" + 42 " * You may obtain a copy of the License at\n" + 43 " *\n" + 44 " * http://www.apache.org/licenses/LICENSE-2.0\n" + 45 " *\n" + 46 " * Unless required by applicable law or agreed to in writing, software\n" + 47 " * distributed under the License is distributed on an \"AS IS\" BASIS,\n" + 48 " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + 49 " * See the License for the specific language governing permissions and\n" + 50 " * limitations under the License.\n" + 51 " */\n\n"; 52 writeTo(Writer writer, int year)53 static final void writeTo(Writer writer, int year) throws IOException { 54 writeTo(writer, year, false); 55 } 56 writeTo(Writer writer, int year, boolean isJavascript)57 static final void writeTo(Writer writer, int year, boolean isJavascript) throws IOException { 58 if (isJavascript) { 59 writer.write(TEXT_OPENING_FOR_JAVASCRIPT); 60 } else { 61 writer.write(TEXT_OPENING); 62 } 63 Formatter formatter = new Formatter(writer); 64 formatter.format(TEXT, year); 65 } 66 } 67