Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.io.StringReader;
import java.util.HashSet;
import java.util.Set;
import javax.xml.stream.XMLInputFactory;

import javax.xml.stream.XMLStreamReader;

public class Main {
    private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    private static Set<String> wellformedSet = new HashSet<String>();

    public static void checkWellformed(String out) throws Exception {

        synchronized (wellformedSet) {
            if (wellformedSet.contains(out)) {
                return;
            }
        }

        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(out));

        do {
            reader.next();
        } while (reader.hasNext());

        synchronized (wellformedSet) {
            wellformedSet.add(out);
        }
    }
}