アットウィキロゴ

次世代統計

package sta;
 
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import tool.*;
 
public class pro {
 
    String urlx;
 String[] data=new String[500000];
 int datanumber,s;
 int s1,s2,sx,creditnumber;   
 int[] ip=new int[100];
 int[] ix=new int[100];
 
 String[] credit=new String[50];
 String[] name=new String[50];
 String[] subdata=new String[50000];
 String[] value=new String[50000];
 String[][] index=new String[50000][50];
 
 String[][] code=new String[50][500];
 String[][] codename=new String[50][500];
 int[] codenumber=new int[100];
 
 int subnumber;
  String[][] title=new String[50000][50];
 
  String id,str;
 
 
    public static void main(String args[]) {
      pro test=new pro();
    }
 
pro(){
 
    id="0000033693";
 
    fastcatch sub=new fastcatch();
    sub.makedata(id);
    datanumber=sub.datanumber;
    data=sub.data;
 
    howcredit sub2=new howcredit();
    sub2.data=data;
    sub2.datanumber=datanumber;
    sub2.makedata();
    code=sub2.code;
    codename=sub2.codename;
    codenumber=sub2.codenumber;
    credit=sub2.credit;
    creditnumber=sub2.creditnumber;
     credit=sub2.credit;
    name=sub2.name;
 
  catchvalue();
 
    change();
 
  writef("data.txt");
 
}
void catchvalue(){
  sx=0;
    for(s=1;s<datanumber+1;s++){
    if(data[s].indexOf("<VALUE")>-1)sx=sx+1;
    if(data[s].indexOf("<VALUE")>-1)subdata[sx]=data[s];
    }
    subnumber=sx;
 
 
    int p1,p2;
 
    for(s=1;s<subnumber+1;s++){
    str=subdata[s];
    p1=str.indexOf(">");
     p2=str.indexOf("<",p1);
   value[s]=str.substring(p1+1,p2);
    }
 
 
 
}
void change(){
String strx;
int p1,p2;    
     for(s=1;s<subnumber+1;s++){
        str=subdata[s];
         for(sx=1;sx<creditnumber+1;sx++){
      strx=credit[sx]+"=";
       p1=str.indexOf(strx);
    p1=str.indexOf("\"",p1);
    p2=str.indexOf("\"",p1+1); 
    index[s][sx]=str.substring(p1+1,p2);   
         }
     }
 
     int tx;
 
  for(s=1;s<subnumber+1;s++){
    for(sx=1;sx<creditnumber+1;sx++){  
     str=index[s][sx];
     for(tx=1;tx<codenumber[sx]+1;tx++){  
     if(str.equals(code[sx][tx]))title[s][sx]=codename[sx][tx];
     }
    }
  }
 
 
 
}
 
void writef(String file){ 
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=1;s<subnumber+1;s++){ 
for(sx=1;sx<creditnumber+1;sx++){     
pw.print("<");
pw.print(name[sx]);
pw.print(">");
pw.print(title[s][sx]);
pw.print("</");
pw.print(name[sx]);
pw.print(">");
}
pw.print("<value>");
pw.print(value[s]);
pw.println("</value>");
 
} 
 
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
}
 
 
 
package sta;
 
 
public class howcredit {
 
 
    String urlx;
 String[] data=new String[500000];
 int datanumber,s;
 int s1,s2,sx,creditnumber;   
 int[] ip=new int[100];
 int[] ix=new int[100];
 
 String[] credit=new String[50];
 String[] name=new String[50];
 String[] subdata=new String[50000];
 String[] value=new String[50000];
 String[][] index=new String[50000][50];
 
 String[][] code=new String[50][500];
 String[][] codename=new String[50][500];
 int[] codenumber=new int[100];
 
 int subnumber;
  String[][] title=new String[50000][50];
 
  String id;
 
 
    void makedata(){
 
    s1=0;
    for(s=1;s<datanumber+1;s++){
    if(data[s].indexOf("<CLASS_INF>")>-1)s1=s;
    }
 
    s2=0;
    for(s=1;s<datanumber+1;s++){
    if(data[s].indexOf("</CLASS_INF>")>-1)s2=s;
    }
 
 
    sx=0;
    for(s=s1;s<s2+1;s++){
    if(data[s].indexOf("<CLASS_OBJ")>-1)sx=sx+1;
    if(data[s].indexOf("<CLASS_OBJ")>-1)ip[sx]=s;
    }
    creditnumber=sx;
 
 
    sx=0;
    for(s=s1;s<s2+1;s++){
    if(data[s].indexOf("</CLASS_OBJ")>-1)sx=sx+1;
    if(data[s].indexOf("</CLASS_OBJ")>-1)ix[sx]=s;
    }
 
    String str;
    int p1,p2,tx;
 
 
    for(s=1;s<creditnumber+1;s++){
    sx=ip[s];
    str=data[sx];
    p1=str.indexOf("id=");
    p1=str.indexOf("\"",p1);
    p2=str.indexOf("\"",p1+1);
    credit[s]=str.substring(p1+1,p2);
    p1=str.indexOf("name=");
    p1=str.indexOf("\"",p1);
    p2=str.indexOf("\"",p1+1);
    name[s]=str.substring(p1+1,p2);
    }
    for(s=1;s<creditnumber+1;s++){
    s1=ip[s];
    s2=ix[s];
    tx=0;
    for(sx=s1+1;sx<s2;sx++){
    tx=tx+1;
    str=data[sx];
    p1=str.indexOf("code=");
    p1=str.indexOf("\"",p1);
    p2=str.indexOf("\"",p1+1);
    code[s][tx]=str.substring(p1+1,p2);
    p1=str.indexOf("name=");
    p1=str.indexOf("\"",p1);
    p2=str.indexOf("\"",p1+1);
    codename[s][tx]=str.substring(p1+1,p2);
    }
    codenumber[s]=tx;    
    }
 
}
}
 
 
package sta;
 
import tool.getdata;
 
public class fastcatch {
 
    String urlx;
String[] data=new String[500000];
 int datanumber,s;
 
 
    void makedata(String id){
 
    urlx="http://statdb.nstac.go.jp/api/1.0b/app/getStatsData?appId=aeec3b02995623cad42b80c80f73d176b7c77970";
    urlx=urlx+"&statsDataId="+id;
 
    getdata sub=new getdata();
    sub.makedata(urlx,"UTF-8");
    datanumber=sub.datanumber;
    data=sub.data;
 
    }
}
 
最終更新:2013年09月23日 08:39