Copyright ? 2014 PEMapModder
This software is open-source and everyone is welcome to share redistributions or modifications,
as long as it is clearly specified that this project's original source is ...
If you think the Android project Spidermine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package pemapmodder.easymod.xml;
/*www.java2s.com*/import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
publicclass Xml {
privatefinalstaticint STATUS_RAW_CONTENT=0x0;
privatefinalstaticint STATUS_ELEMENT_NAME=0x1;
privatefinalstaticint STATUS_ATTRIBUTE_NAME=0x2;
privatefinalstaticint STATUS_ATTRIBUTE_VAL_ONE=0x3;
privatefinalstaticint STATUS_ATTRIBUTE_VAL_SGL_QUOTE=0x4;
privatefinalstaticint STATUS_ATTRIBUTE_VAL_DBL_QUOTE=0x5;
privatefinalstaticint STATUS_COMMENT=0x6;
Element[] elements={};
@SuppressWarnings("unused")
private Xml(String src) throws XmlLangException{
int nestTags=0;
String[] nests={};
int memory=-1;
int status=STATUS_RAW_CONTENT;
String[] buffer={
"","","","","","","","","",""
};
int line=0;
for(int i=0; i<src.length(); i++){
char tc=src.charAt(i);
if(i==0&&tc!='<')
thrownew XmlLangException(line);
if(tc=='\n'){
line++;
continue;
}
switch(status){
case STATUS_RAW_CONTENT:
if(tc=='<'){
status=STATUS_ELEMENT_NAME;
continue;
}
//TODO
break;
case STATUS_ELEMENT_NAME:
if(tc==' '){
nestTags++;
status=STATUS_ATTRIBUTE_NAME;
continue;
}
buffer[1]+=tc;
break;
case STATUS_ATTRIBUTE_NAME:
break;
case STATUS_ATTRIBUTE_VAL_ONE:
break;
case STATUS_ATTRIBUTE_VAL_SGL_QUOTE:
case STATUS_ATTRIBUTE_VAL_DBL_QUOTE:
break;
case STATUS_COMMENT:
break;
}
}
}
publicstatic Xml parse(File f)
throws IOException, XmlLangException{
returnnew Xml(readFile(f));
}
publicstatic String readFile(File f)throws IOException{
BufferedReader br=new BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(f)));
String ret="";
try{
String line;
while((line = br.readLine()) != null)
ret += (line+"\n");
}catch(IOException e){
br.close();
throw e;
}
br.close();
return ret;
}
}