Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String extractDomType(String input) {
        return extractAttribute(input, "type");
    }

    public static String extractAttribute(String input, String attribute) {
        String[] split = input.split(attribute + "=");
        if (split.length == 1) {
            split = input.split(attribute + " =");
        }
        if (split.length > 1) {
            String lastPart = split[1];
            if (lastPart == null) {
                return null;
            }
            if (lastPart.charAt(0) == '"' || lastPart.charAt(0) == '\'') {
                int endIndex = -1;
                for (int i = 1; i < lastPart.length(); i++) {
                    if (lastPart.charAt(i) == '\'' || lastPart.charAt(i) == '"') {
                        endIndex = i;
                        break;
                    }
                }

                if (endIndex > 0) {
                    return lastPart.substring(1, endIndex);
                }

            }
        }
        return null;

    }
}