Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.swing.text.BadLocationException;
import javax.swing.text.Document;

public class Main {
    private static int getTagEnd(Document doc, int p) {
        int elementEnd = 0;

        if (p > 0) {
            try {
                int index = 0;

                String s = doc.getText(0, p);
                int commentStart = s.lastIndexOf("<!--");
                int commentEnd = s.lastIndexOf("-->");

                if (commentStart > 0 && commentStart > commentEnd) {
                    index = s.lastIndexOf(">", commentStart);
                } else {
                    index = s.lastIndexOf(">");
                }

                if (index != -1) {
                    elementEnd = index;
                }
            } catch (BadLocationException bl) {
            }
        }

        return elementEnd;
    }
}