/** Text Parser
 *
 *	@version 0.5 08/08/2003
 *	@author Pascal Vuylsteker
 */
 

import java.util.*;
import java.io.*;
import java.util.regex.*;

public class ParserPVK	{	

static final int	MAP 				= 1;
static final int	MAP_DESCRIPTION 	= 2;
static final int	POINTS 				= 3;
static final int	POINT 				= 4;
static final int	POINT_DESCRIPTION 	= 5;
static String 		mapName;
static String 		mapDescription;
static double		mapWidth, mapHeigth;

Point points[]	=	new Point[10];

	public static void main(String[] args)	{	
			
		Point points[]	=	new Point[10];
		for(int i=0; i<10; i++)	{
			points[i] = new Point();
		}
				
		int	nbPoints = -1;
		int status = 0;
		
		try	{
				BufferedReader configVOT = new BufferedReader(new InputStreamReader(
						new FileInputStream("canberraCenter.vot")));
						
				// Match comment line and empty line. You should directly get rid of those matches
				Pattern patComment = Pattern.compile("^(\\s*|#.*)$"); 
				Matcher matComment = patComment.matcher(""); 
				
				// Begining of a Map
				Pattern patMap = Pattern.compile("^\\s*Map\\s*:\\s*$");
				Matcher matMap = patMap.matcher(""); 

				// Name of a Map or of a Point
				Pattern patName = Pattern.compile("^\\s*Name\\s*:\\s*(.*)\\s*$");
				Matcher matName = patName.matcher(""); 

				// Begining of a Point 
				Pattern patPoint = Pattern.compile("^\\s*Point\\s*:\\s*$");
				Matcher matPoint = patPoint.matcher(""); 

				String line;
				while ( ( line=configVOT.readLine() ) != null )	{
						matComment.reset(line);  
						if (matComment.matches())	{
							// System.out.println("Comment : " + matComment.group(1));
							// This line has been recognised, as a comment, 
							// therefore, you don't need to keep testing it
							continue;
						}
						
						matMap.reset(line);
						if (matMap.matches())	{
							System.out.println("New Map : ");
							status = MAP;
							// This line has been recognised, ...
							continue;
						}
						
						matName.reset(line);
						if (matName.matches())	{
							if (status == MAP)	{
								mapName = matName.group(1);
								System.out.println("Map Name : " + mapName);
							}
							else if (status == POINT)	{
								points[nbPoints].name = matName.group(1);
								System.out.println("Point" + nbPoints + " Name : " + points[nbPoints].name);
							}
							continue;
						}

						
						matPoint.reset(line);
						if (matPoint.matches())	{
							status = POINT;
							nbPoints++;
							System.out.println("New Point : " + nbPoints);
							continue;
						}
						
					// When you arrive at that point in the loop, you are supposed to have checked
					// any possible tag. The only remaining possibility is that you are
					// dealing with a continuing line from a 'Description' field (they are the only lines
					// that contain not beginning tags
					// by looking at the current status (that would be either MAP_DESCRIPTION or
					// POINT_DESCRIPTION, your are able to decide where you should append that line
						
				}

				configVOT.close();
		}
		catch( Exception ex )	{
				System.err.println( ex.getMessage() );
		}

		System.out.println("\n\nEnd of File :\n\n");

	}
}

class Point {
	public double 		x,y;
	public String 		name;
	public String		description;
	public String[] 	images;
	public int			nbImages;
	
	public Point()	{
		images = new String[10];
	
	}
	
}