1 | /**
|
---|
2 | * TexEnvironment.java
|
---|
3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | package org.expeditee.io;
|
---|
20 |
|
---|
21 | public class TexEnvironment {
|
---|
22 | private String _comment = "";
|
---|
23 |
|
---|
24 | private String _name = "";
|
---|
25 |
|
---|
26 | public TexEnvironment(String s) {
|
---|
27 | int colonPos = s.indexOf(':');
|
---|
28 |
|
---|
29 | if (colonPos > 0) {
|
---|
30 | _name = s.substring(0, colonPos).trim();
|
---|
31 | if (s.length() > colonPos + 1)
|
---|
32 | _comment = s.substring(colonPos + 1).trim();
|
---|
33 |
|
---|
34 | for (int i = 0; i < _name.length(); i++) {
|
---|
35 | if (!Character.isLetter(_name.charAt(i))) {
|
---|
36 | _name = "";
|
---|
37 | }
|
---|
38 | }
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | public boolean isValid() {
|
---|
43 | return _name != "";
|
---|
44 | }
|
---|
45 |
|
---|
46 | public String getComment() {
|
---|
47 | return _comment;
|
---|
48 | }
|
---|
49 |
|
---|
50 | public String getName() {
|
---|
51 | return _name;
|
---|
52 | }
|
---|
53 |
|
---|
54 | public boolean hasComment() {
|
---|
55 | return _comment != "";
|
---|
56 | }
|
---|
57 | }
|
---|