Java HashSet Create isValidTagException(HashSet tagExceptions, String buffer)

Here you can find the source of isValidTagException(HashSet tagExceptions, String buffer)

Description

is Valid Tag Exception

License

Open Source License

Declaration

private static boolean isValidTagException(HashSet tagExceptions,
            String buffer) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright (c) 2006, 2011 IBM Corporation and others.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 * /* w  w w . ja v a 2 s .  co m*/
 *  Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

import java.util.*;

public class Main {
    private static boolean isValidTagException(HashSet tagExceptions,
            String buffer) {
        // Sample buffer format:
        // NO '<'
        // tagName att1="value" att2="value"
        // NO '>'
        // Parse tag name and ignore attributes (if any specified)
        String tagName = getTagName(buffer);
        // Check to see if the tag name is a tag exception
        if (tagExceptions.contains(tagName)) {
            return true;
        }
        return false;
    }

    private static String getTagName(String buffer) {
        // Sample buffer format:
        // NO '<'
        // tagName att1="value" att2="value"
        // NO '>'      
        StringBuffer tagName = new StringBuffer();
        // The tag name is every non-whitespace character in the buffer until
        // a whitespace character is encountered
        for (int i = 0; i < buffer.length(); i++) {
            char character = buffer.charAt(i);
            if (Character.isWhitespace(character)) {
                break;
            }
            tagName.append(character);
        }
        return tagName.toString();
    }
}

Related

  1. hashset_to_int_array(Set hs)
  2. hashSetFromArray(final T[] objs)
  3. hashSetOf(T... elements)
  4. hashSetOf(T... ts)
  5. identityHashSet()
  6. newHashSet(boolean optimized, T... array)
  7. newHashSet(E... elements)
  8. newHashSet(E... elements)
  9. newHashSet(E... elements)