gpt4 book ai didi

java - 对象作为文字的父级

转载 作者:行者123 更新时间:2023-12-01 05:01:49 25 4
gpt4 key购买 nike

我正在为我的应用程序构建一个帮助系统。帮助系统由带有工具栏树和浏览器 Pane 的外壳组成。树将文件加载到节点中,单击链接时会在浏览器中打开 HTML 文件。当单击工具栏上的按钮时,将调用 text = browser.getText() ,并通过缓冲区将文本加载到 HTML 标签剥离器,该标签剥离器被收集在三个数组中,然后解析到 styledtext 编辑器的样式创建器。

  • 缓冲区集成在标签读取器类中,我想创建一个全局类,以便在应用程序中的任何地方需要时使用它,但在解析到 buffer.class 时遇到常量字符字符串等问题
  • 该数组由三个数组组成,其中填充了阅读器找到的标签,我希望 add 方法全局工作,以便在需要的应用程序中使用它。

  • 我可以使用 List list = new ArrayList();但为了便于使用开销和更好地理解,我尝试仅使用数组。

    public class XMLHtmlTagReader {
    private static char startchar = '<';
    private static char endchar= '>';
    private static char[] closingchar ={'<','/'};
    private static String startTag;
    private static String endTag;
    private static String tagValue;
    static String[] starttaglist = new String[]{"first","second","third","fourth"};
    static String[]tagvaluelist;// = new String[1];
    static String[] endtaglist;// = new String[1];
    int tagcount=0;
    static char newchar;
    static char newchar1;
    static int i=0;
    static int startcharint = -1;
    static int endcharint = -1;
    static int closingcharint = -1;
    static int level=0;
    static int elm=0;
    boolean closing = false;
    static Object store[] = new Object[26];
    Object[][][] megastore = new Object[50][50][50];
    int storeCounter = 0;
    int count=-1;
    int Wmstore=0,WstoreCounter=0,Wv=0;
    int Rmstore=0;
    static int RstoreCounter=0;
    static int Rv=0;
    static int Rtmp;
    int Omstore=0;
    static int OstoreCounter=0;
    static int Ov=0;
    int mstore=0;
    long time = 3087;

    public static void main(String[] args) {
    XMLHtmlTagReader run=new XMLHtmlTagReader();
    }

    XMLHtmlTagReader(){
    long memstart = (Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory());
    System.out.println("Memory at start:"+memstart);
    long startTime = System.nanoTime();
    getStream("<html><title>hallo de titel ...</title><p>Dit is de text.</p><b>dikke text</b></html>");
    //for(int t=0;t<100000;t++){new com.pim.Buffer(endchar);}
    long estimatedTime = (System.nanoTime() - startTime);
    //(System.currentTimeMillis() - startTime);
    //(System.nanoTime() - startTime)/1000000;
    //long calc = (estimatedTime/time)*100;
    System.out.println(memstart+"memstart "+"execution time = "+estimatedTime+" is % sneller/langzamer = "+(estimatedTime/time)*100+"Memory = "+(Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()));
    bufferWrite('E');
    }

    public static String getStream(String input) {

    while(input != null){
    i++;
    try {
    newchar = input.charAt(i);
    }
    catch (java.lang.StringIndexOutOfBoundsException exception){
    break;
    }
    if(newchar!=closingchar[1]&&input.charAt(i-1)==startchar){
    startcharint=i;
    level++;
    }
    if(newchar==closingchar[1]&&input.charAt(i-1)==startchar) {
    closingcharint=i;
    tagValue = input.substring(endcharint+1,closingcharint-1);
    if(tagValue!=null){log("valuetag ["+tagValue+"]->"+endcharint+" ->"+closingcharint);}
    }
    if(newchar==endchar) {
    endcharint=i;
    if(startcharint>=0){
    startTag = input.substring(startcharint-1,endcharint+1);
    log("starttag "+startTag);
    }
    else {startTag=" no Start tag found "; }
    if(closingcharint>0){
    endTag = input.substring(closingcharint-1,endcharint+1);
    level--;
    log("endtag->"+endTag);
    log("level->"+level);
    }
    else { endTag=" no end tag found "; }
    closingcharint=0;
    startcharint=-1;
    }
    }
    startchar = 0;
    endchar = 0;
    closingchar = null;
    newchar = 0;
    newchar1 = 0;
    return input;
    }
    private static void addElementToArray(String string){
    String[] tmpArray;
    int length = starttaglist.length;
    tmpArray = new String[length+1];
    System.arraycopy(starttaglist, 0,tmpArray , 0, length);
    tmpArray[length] = new String(string);
    starttaglist = null;
    starttaglist = new String[length+1];
    System.arraycopy(tmpArray, 0,starttaglist , 0, length+1);
    for(String tmp:starttaglist){
    System.out.println("Elements in Array "+tmp);
    }
    tmpArray = null;
    }
    public static String[] getStartTag(){
    return starttaglist;
    }
    public static String[] getTagValue(){
    for(String tmp:tagvaluelist){

    }
    return tagvaluelist;
    }
    public static String[] getEndTag(){
    return endtaglist;
    }


    static Object bufferWrite(char value){
    store[OstoreCounter] = new Object();
    store[OstoreCounter] = value;
    //System.out.println("bufferWrite=["+OstoreCounter+"] storeValue=["+store[OstoreCounter]+"] Ov="+Ov);
    if(Ov==30&&store[RstoreCounter] == null){
    Rtmp=Ov;
    Ov=0;
    }
    if(Ov==40){
    OstoreCounter++;
    Ov=0;
    }
    Ov++;
    char tmp = (char) bufferRead();
    return tmp;
    }

    static Object bufferRead(){
    Object tmp = store[RstoreCounter];
    //System.out.println("bufferRead=["+RstoreCounter+"] storeValue= ["+store[RstoreCounter]+"] Rv="+Rv);
    store[RstoreCounter] = null;
    if(Rv==Rtmp){
    Rv=0;
    }
    if(Rv==40){
    RstoreCounter++;
    Rv=0;
    }
    //System.out.println("bufferRead reads till end of int"+Rtmp);
    Rv++;
    return tmp;
    }




    static void log(String txt){
    System.out.println(txt);
    }
    }

最佳答案

int 不是对象

尝试一下

Integer i = new Integer[10];

这会起作用

关于java - 对象作为文字的父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13302998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com