es.prodevelop.gvsig.mobile.project
Class ProjectDeserializer

java.lang.Object
  extended byes.prodevelop.gvsig.mobile.project.ProjectDeserializer

public class ProjectDeserializer
extends java.lang.Object

This class instantiates a full project from a XML file.

Author:
jcarrasco
See Also:
Project, ProjectSerializer

Constructor Summary
ProjectDeserializer()
           
 
Method Summary
static java.awt.geom.Rectangle2D deSerializeBounds(org.kxml2.io.KXmlParser parser, Project prj)
          Gets the new available data from the parser as a Rectangle2D
static FLayer deSerializeLayer(org.kxml2.io.KXmlParser parser, Project prj)
          Deserializes (instantiates) a single layer from a project file.
static java.util.ArrayList deSerializeLayers(org.kxml2.io.KXmlParser parser, Project prj)
          Extracts the data from the parser to instantiate the layers contained in it.
static void deSerializeLineSymbol(org.kxml2.io.KXmlParser parser, FSymbol simb)
          Updates a symbol with the data deserialized from a project file.
static void deSerializePointSymbol(org.kxml2.io.KXmlParser parser, FSymbol simb)
          Updates a symbol with the data deserialized from a project file.
static void deSerializePolygonSymbol(org.kxml2.io.KXmlParser parser, FSymbol simb)
          Updates a symbol with the data deserialized from a project file.
static Project deSerializeProject(java.io.File f, java.awt.Dimension d)
          This method instantiates a project from a given XML file and a canvas size
static Project deSerializeProject(org.kxml2.io.KXmlParser parser, java.awt.Dimension d, Project prj)
          Updates teh provided project with the given canvas size and the data found by the provided parser.
static FSymbol deSerializeSymbol(org.kxml2.io.KXmlParser parser)
          Gets the new available data from the parser as a FSymbol
static boolean getbool(org.kxml2.io.KXmlParser parser)
          Gets the new available data from the parser as a boolean
static java.awt.Color getcolor(org.kxml2.io.KXmlParser parser)
          Gets the new available data from the parser as a Color
static java.util.Date getDate(org.kxml2.io.KXmlParser parser)
          Gets the new available data from the parser as a Date
static double getdbl(org.kxml2.io.KXmlParser parser)
          Gets the new available data from the parser as a double
static java.io.File getFile(java.io.File projectFile, java.lang.String filePath)
          gets the full path name of a file.
static int getint(org.kxml2.io.KXmlParser parser)
          Gets the new available data from the parser as a int
static boolean isPathRelative(java.lang.String path)
          Returns true if the indicated path is relative and false if it is absolute
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectDeserializer

public ProjectDeserializer()
Method Detail

deSerializeProject

public static Project deSerializeProject(java.io.File f,
                                         java.awt.Dimension d)
This method instantiates a project from a given XML file and a canvas size

Parameters:
f - XML file where the project is stored
d - canvas size where the project will be opened
Returns:
the project object fully instantiated.

deSerializeProject

public static Project deSerializeProject(org.kxml2.io.KXmlParser parser,
                                         java.awt.Dimension d,
                                         Project prj)
                                  throws java.io.IOException,
                                         org.xmlpull.v1.XmlPullParserException
Updates teh provided project with the given canvas size and the data found by the provided parser.

Parameters:
parser - the parser that will search for more project data
d - the size of the canvas where the project has to be opened
prj - the project taht is being updated
Returns:
the updated project
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

deSerializeLayers

public static java.util.ArrayList deSerializeLayers(org.kxml2.io.KXmlParser parser,
                                                    Project prj)
                                             throws java.io.IOException,
                                                    org.xmlpull.v1.XmlPullParserException
Extracts the data from the parser to instantiate the layers contained in it.

Parameters:
parser - the parser that is reading the project file
prj - the project that is in the process of being deserialized.
Returns:
an an array list containing the layers found in the layers section of the project file
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

getdbl

public static double getdbl(org.kxml2.io.KXmlParser parser)
                     throws java.io.IOException,
                            org.xmlpull.v1.XmlPullParserException
Gets the new available data from the parser as a double

Parameters:
parser - the parser where the data comes from
Returns:
the new available data from the parser as a double
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

getint

public static int getint(org.kxml2.io.KXmlParser parser)
                  throws java.io.IOException,
                         org.xmlpull.v1.XmlPullParserException
Gets the new available data from the parser as a int

Parameters:
parser - the parser where the data comes from
Returns:
the new available data from the parser as a int
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

getbool

public static boolean getbool(org.kxml2.io.KXmlParser parser)
                       throws java.io.IOException,
                              org.xmlpull.v1.XmlPullParserException
Gets the new available data from the parser as a boolean

Parameters:
parser - the parser where the data comes from
Returns:
the new available data from the parser as a boolean
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

getDate

public static java.util.Date getDate(org.kxml2.io.KXmlParser parser)
                              throws java.io.IOException,
                                     org.xmlpull.v1.XmlPullParserException,
                                     java.text.ParseException
Gets the new available data from the parser as a Date

Parameters:
parser - the parser where the data comes from
Returns:
the new available data from the parser as a Date
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException
java.text.ParseException

getcolor

public static java.awt.Color getcolor(org.kxml2.io.KXmlParser parser)
                               throws java.io.IOException,
                                      org.xmlpull.v1.XmlPullParserException
Gets the new available data from the parser as a Color

Parameters:
parser - the parser where the data comes from
Returns:
the new available data from the parser as a Color
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

deSerializeBounds

public static java.awt.geom.Rectangle2D deSerializeBounds(org.kxml2.io.KXmlParser parser,
                                                          Project prj)
                                                   throws java.io.IOException,
                                                          org.xmlpull.v1.XmlPullParserException
Gets the new available data from the parser as a Rectangle2D

Parameters:
parser - the parser where the data comes from
prj - the project that is in the process of being deserialized
Returns:
the new available data from the parser as a Rectangle2D
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

deSerializeSymbol

public static FSymbol deSerializeSymbol(org.kxml2.io.KXmlParser parser)
                                 throws java.io.IOException,
                                        org.xmlpull.v1.XmlPullParserException
Gets the new available data from the parser as a FSymbol

Parameters:
parser - the parser where the data comes from
Returns:
the new available data from the parser as a FSymbol
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

deSerializePolygonSymbol

public static void deSerializePolygonSymbol(org.kxml2.io.KXmlParser parser,
                                            FSymbol simb)
                                     throws java.io.IOException,
                                            org.xmlpull.v1.XmlPullParserException
Updates a symbol with the data deserialized from a project file.

Parameters:
parser - the parser where the data comes from
simb - the symbol that is being updated
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

deSerializeLineSymbol

public static void deSerializeLineSymbol(org.kxml2.io.KXmlParser parser,
                                         FSymbol simb)
                                  throws java.io.IOException,
                                         org.xmlpull.v1.XmlPullParserException
Updates a symbol with the data deserialized from a project file.

Parameters:
parser - the parser where the data comes from
simb - the symbol that is being updated
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

deSerializePointSymbol

public static void deSerializePointSymbol(org.kxml2.io.KXmlParser parser,
                                          FSymbol simb)
                                   throws java.io.IOException,
                                          org.xmlpull.v1.XmlPullParserException
Updates a symbol with the data deserialized from a project file.

Parameters:
parser - the parser where the data comes from
simb - the symbol that is being updated
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

deSerializeLayer

public static FLayer deSerializeLayer(org.kxml2.io.KXmlParser parser,
                                      Project prj)
                               throws java.io.IOException,
                                      org.xmlpull.v1.XmlPullParserException
Deserializes (instantiates) a single layer from a project file.

Parameters:
parser - the parser where the data comes from
prj - the project that is in the process of being deserialized
Returns:
the next layer found in the project file
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

getFile

public static java.io.File getFile(java.io.File projectFile,
                                   java.lang.String filePath)
gets the full path name of a file. If it is a relative path, this method will find out the full path by reading the project properties.

Parameters:
projectFile - the project file where the file path is cited
filePath - the possibly relative file path
Returns:
the full path name of a file

isPathRelative

public static boolean isPathRelative(java.lang.String path)
Returns true if the indicated path is relative and false if it is absolute