Changeset 67 for trunk/src/org/expeditee/io/KMSReader.java
- Timestamp:
- 05/19/08 12:03:18 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/io/KMSReader.java
r4 r67 1 1 package org.expeditee.io; 2 2 3 import java.awt.Color;4 import java.awt.Font;5 import java.awt.Point;6 3 import java.io.BufferedReader; 7 4 import java.io.FileReader; … … 13 10 import java.util.Iterator; 14 11 import java.util.LinkedHashMap; 15 import java.util.List;16 12 17 13 import org.expeditee.gui.Frame; … … 30 26 * 31 27 */ 32 public class KMSReader implements FrameReader {28 public class KMSReader extends FrameReader { 33 29 34 30 private BufferedReader _reader = null; … … 48 44 _FrameTags = new LinkedHashMap<String, Method>(); 49 45 50 Class[] pString = { String.class };51 Class[] pInt = { int.class };52 Class[] pFloat = { float.class };53 Class[] pColor = { Color.class };54 Class[] pBool = { boolean.class };55 Class[] pFont = { Font.class };56 Class[] pPoint = { Point.class };57 Class[] pArrow = { int.class, double.class };58 Class[] pList = { List.class };59 Class[] pIntArray = { int[].class };60 Class[] pItem = { Item.class };61 62 46 try { 63 47 _FrameTags.put("A", Frame.class.getMethod("setFrameName", pString)); 64 48 _FrameTags.put("V", Frame.class.getMethod("setVersion", pInt)); 65 _FrameTags66 .put("v", Frame.class.getMethod("setFormatVersion", pInt));67 49 _FrameTags 68 50 .put("p", Frame.class.getMethod("setProtection", pString)); … … 152 134 * @return true if s begins with a KMS tag 153 135 */ 154 private boolean isValidLine(String s) {136 private static boolean isValidLine(String s) { 155 137 return s.length() >= 3 && s.charAt(0) == '+' && s.charAt(2) == '+' 156 138 && Character.isLetter(s.charAt(1)); … … 332 314 } 333 315 334 private String getTag(String line) {316 private static String getTag(String line) { 335 317 assert (line.charAt(0) == '+'); 336 318 assert (line.length() > 2); … … 338 320 } 339 321 340 private String getValue(String line) {322 private static String getValue(String line) { 341 323 assert (line.charAt(0) == '+'); 342 324 if (line.length() > 4) … … 365 347 366 348 if (_FrameTags.get(tag) == null) { 367 if (!tag.equals("t") )349 if (!tag.equals("t") && !tag.equals("v") ) 368 350 FrameGraphics.ErrorMessage("Tag '" + tag + "' in '" + line 369 351 + "' is not supported."); … … 530 512 return toMake; 531 513 } 514 515 public static int getVersion(String fullpath) { 516 try { 517 BufferedReader reader = new BufferedReader(new FileReader(fullpath)); 518 String next = ""; 519 // First read the header lines until we get the version number 520 while (reader.ready() && (next = reader.readLine())!= null) { 521 if (isValidLine(next)) { 522 char tag = getTag(next).charAt(0); 523 String value = getValue(next); 524 if (tag == 'V') 525 return Integer.parseInt(value); 526 else if(tag == 'Z') 527 return 0; 528 } 529 } 530 } catch (Exception e) { 531 } 532 return 0; 533 } 532 534 }
Note:
See TracChangeset
for help on using the changeset viewer.