Here you can find the source of parseHtmlProperties(String s)
Parameter | Description |
---|---|
s | the string |
public static Hashtable parseHtmlProperties(String s)
//package com.java2s; import java.util.*; public class Main { /**//from ww w. ja v a 2s.c om * Parse HTML Properties * * @param s the string * @return a hashtable of properties */ public static Hashtable parseHtmlProperties(String s) { // boolean debug = true; boolean debug = false; Hashtable properties = new Hashtable(); // debug = true; if (debug) { System.err.println("Source:" + s); } while (true) { if (debug) { System.err.println("S:" + s); } int idx = s.indexOf("="); if (idx < 0) { s = s.trim(); if (s.length() > 0) { if (debug) { System.err.println("\tsingle name:" + s + ":"); } properties.put(s, ""); } break; } String name = s.substring(0, idx).trim(); s = s.substring(idx + 1).trim(); if (s.length() == 0) { if (debug) { System.err.println("\tsingle name=" + name); } properties.put(name, ""); break; } if (s.charAt(0) == '\"') { s = s.substring(1); idx = s.indexOf("\""); if (idx < 0) { //no closing "=" properties.put(name, s); break; } String value = s.substring(0, idx); if (debug) { System.err.println("\tname=" + name); } if (debug) { System.err.println("\tvalue=" + value); } properties.put(name, value); s = s.substring(idx + 1); } else { idx = s.indexOf(" "); if (idx < 0) { if (debug) { System.err.println("\tname=" + name); } if (debug) { System.err.println("\tvalue=" + s); } properties.put(name, s); break; } String value = s.substring(0, idx); properties.put(name, value); if (debug) { System.err.println("\tname=" + name); } if (debug) { System.err.println("\tvalue=" + value); } s = s.substring(idx + 1); } } if (debug) { System.err.println("props:" + properties); } return properties; } }