001: /*
002: * This file is part of the GeOxygene project source files.
003: *
004: * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for
005: * the development and deployment of geographic (GIS) applications. It is a open source
006: * contribution of the COGIT laboratory at the Institut Géographique National (the French
007: * National Mapping Agency).
008: *
009: * See: http://oxygene-project.sourceforge.net
010: *
011: * Copyright (C) 2005 Institut Géographique National
012: *
013: * This library is free software; you can redistribute it and/or modify it under the terms
014: * of the GNU Lesser General Public License as published by the Free Software Foundation;
015: * either version 2.1 of the License, or any later version.
016: *
017: * This library is distributed in the hope that it will be useful, but WITHOUT ANY
018: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
019: * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
020: *
021: * You should have received a copy of the GNU Lesser General Public License along with
022: * this library (see file LICENSE if present); if not, write to the Free Software
023: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024: *
025: */
026:
027: package fr.ign.cogit.geoxygene.util.loader;
028:
029: import java.io.BufferedReader;
030:
031: /**
032: * Usage interne. Outil pour écrire des message en console, et pour lire les réponses.
033: *
034: * @author Thierry Badard & Arnaud Braun
035: * @version 1.0
036: *
037: */
038:
039: public class Message {
040:
041: private String prompt;
042: private String choix1;
043: private String choix2;
044: private String reponse;
045:
046: public Message(BufferedReader br, String prompt, String choix1,
047: String choix2) {
048: reponse = "";
049: try {
050: while (!((reponse.compareToIgnoreCase(choix1) == 0)
051: || (reponse.compareToIgnoreCase(choix2) == 0) || (reponse
052: .compareToIgnoreCase("q") == 0))) {
053: System.out.println(prompt + " (" + choix1 + "/"
054: + choix2 + "/q)");
055: reponse = br.readLine();
056: }
057: } catch (Exception e) {
058: e.printStackTrace();
059: }
060: if (reponse.compareToIgnoreCase("q") == 0) {
061: System.out.println("Au revoir");
062: System.exit(0);
063: }
064: }
065:
066: public Message(BufferedReader br, String prompt, String choix1,
067: String choix2, String choix3, String choix4) {
068: reponse = "";
069: try {
070: while (!((reponse.compareToIgnoreCase(choix1) == 0)
071: || (reponse.compareToIgnoreCase(choix2) == 0)
072: || (reponse.compareToIgnoreCase(choix3) == 0)
073: || (reponse.compareToIgnoreCase(choix4) == 0) || (reponse
074: .compareToIgnoreCase("q") == 0))) {
075: System.out.println(prompt + " (" + choix1 + "/"
076: + choix2 + "/" + choix3 + "/" + choix4 + "/q)");
077: reponse = br.readLine();
078: }
079: } catch (Exception e) {
080: e.printStackTrace();
081: }
082: if (reponse.compareToIgnoreCase("q") == 0) {
083: System.out.println("Au revoir");
084: System.exit(0);
085: }
086: }
087:
088: public Message(BufferedReader br, String prompt, String choix1,
089: String choix2, String choix3) {
090: reponse = "";
091: try {
092: while (!((reponse.compareToIgnoreCase(choix1) == 0)
093: || (reponse.compareToIgnoreCase(choix2) == 0)
094: || (reponse.compareToIgnoreCase(choix3) == 0) || (reponse
095: .compareToIgnoreCase("q") == 0))) {
096: System.out.println(prompt + " (" + choix1 + "/"
097: + choix2 + "/" + choix3 + "/q)");
098: reponse = br.readLine();
099: }
100: } catch (Exception e) {
101: e.printStackTrace();
102: }
103: if (reponse.compareToIgnoreCase("q") == 0) {
104: System.out.println("Au revoir");
105: System.exit(0);
106: }
107: }
108:
109: public Message(BufferedReader br, String prompt) {
110: System.out.println(prompt);
111: try {
112: reponse = br.readLine();
113: } catch (Exception e) {
114: e.printStackTrace();
115: }
116: }
117:
118: public String getAnswer() {
119: return reponse;
120: }
121:
122: }
|