Here you can find the source of getTagName(Node tag, boolean useJsfcTags)
Parameter | Description |
---|---|
tag | a parameter |
useJsfcTags | a parameter |
public static String getTagName(Node tag, boolean useJsfcTags)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009 Red Hat, Inc. /*from w w w .j a v a 2 s . c o m*/ * Distributed under license by Red Hat, Inc. All rights reserved. * This program is 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 * * Contributors: * Red Hat, Inc. - initial API and implementation ******************************************************************************/ import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { private static final String JSFC_ATTRIBUTE_NAME = "jsfc"; /** * Returns the name for the tag * * @param tag * @param useJsfcTags * @return */ public static String getTagName(Node tag, boolean useJsfcTags) { String tagName = tag.getNodeName(); if (useJsfcTags) { // Only HTML tags if (tagName.indexOf(':') > 0) { return tagName; } if (!(tag instanceof Element)) return tagName; Element element = (Element) tag; NamedNodeMap attributes = element.getAttributes(); Node jsfC = attributes.getNamedItem(JSFC_ATTRIBUTE_NAME); if (jsfC == null || (!(jsfC instanceof Attr))) { return tagName; } Attr jsfCAttribute = (Attr) jsfC; String jsfTagName = jsfCAttribute.getValue(); if (jsfTagName == null || jsfTagName.indexOf(':') < 1) { return tagName; } tagName = jsfTagName; } return tagName; } }