本文整理汇总了Java中org.pentaho.di.core.xml.XMLHandler.getTagAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java XMLHandler.getTagAttribute方法的具体用法?Java XMLHandler.getTagAttribute怎么用?Java XMLHandler.getTagAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.xml.XMLHandler
的用法示例。
在下文中一共展示了XMLHandler.getTagAttribute方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseXmlForAdditionalClasses
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
public void parseXmlForAdditionalClasses() throws KettleException{
try {
Properties sysprops = System.getProperties();
String strActPath = sysprops.getProperty("user.dir");
Document dom = XMLHandler.loadXMLFile(strActPath + "/plugins/steps/ScriptValues_mod/plugin.xml");
Node stepnode = dom.getDocumentElement();
Node libraries = XMLHandler.getSubNode(stepnode, "js_libraries");
int nbOfLibs = XMLHandler.countNodes(libraries, "js_lib");
additionalClasses = new ScriptValuesAddClasses[nbOfLibs];
for(int i=0;i<nbOfLibs;i++){
Node fnode = XMLHandler.getSubNodeByNr(libraries, "js_lib", i);
String strJarName = XMLHandler.getTagAttribute(fnode, "name");
String strClassName =XMLHandler.getTagAttribute(fnode, "classname");
String strJSName = XMLHandler.getTagAttribute(fnode, "js_name");
Class<?> addClass = LoadAdditionalClass(strActPath + "/plugins/steps/ScriptValues_mod/"+ strJarName,strClassName);
Object addObject = addClass.newInstance();
additionalClasses[i] = new ScriptValuesAddClasses(addClass, addObject, strJSName);
}
}catch(Exception e) {
throw new KettleException(Messages.getString("ScriptValuesMetaMod.Exception.UnableToParseXMLforAdditionalClasses"), e);
}
}
示例2: createPopupMenusFromXul
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
public static Map<String,Menu> createPopupMenusFromXul( Document doc, Shell shell, Messages xulMessages, List<String> menuIds ) {
NodeList list = doc.getElementsByTagName( "popupset" ); //$NON-NLS-1$
Map<String,Menu> map = new HashMap<String,Menu>();
if( list != null && list.getLength() > 0 ) {
Node popupSetNode = list.item( 0 );
// get the top level menus
Node menuNode = XMLHandler.getSubNode( popupSetNode, "menupopup" ); //$NON-NLS-1$
while( menuNode != null ) {
if( "menupopup".equals( menuNode.getNodeName() ) ) { //$NON-NLS-1$
// create a top-level item
String id = XMLHandler.getTagAttribute( menuNode, "id" ); //$NON-NLS-1$
if( menuIds.contains( id ) ) {
Menu menu = new PopupMenu(shell, id );
map.put( id, menu );
// create a submenu if it exists
createMenuFromXul( menu, menuNode, xulMessages ); //$NON-NLS-1$
}
}
// see if there are more options
menuNode = menuNode.getNextSibling();
}
}
return map;
}
示例3: createAllPopupMenusFromXul
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
public static Map<String,Menu> createAllPopupMenusFromXul( Document doc, Shell shell, Messages xulMessages ) {
NodeList list = doc.getElementsByTagName( "popupset" ); //$NON-NLS-1$
Map<String,Menu> map = new HashMap<String,Menu>();
if( list != null && list.getLength() > 0 ) {
Node popupSetNode = list.item( 0 );
// get the top level menus
Node menuNode = XMLHandler.getSubNode( popupSetNode, "menupopup" ); //$NON-NLS-1$
while( menuNode != null ) {
if( "menupopup".equals( menuNode.getNodeName() ) ) { //$NON-NLS-1$
// create a top-level item
String id = XMLHandler.getTagAttribute( menuNode, "id" ); //$NON-NLS-1$
Menu menu = new PopupMenu(shell, id );
map.put( id, menu );
// create a submenu if it exists
createMenuFromXul( menu, menuNode, xulMessages ); //$NON-NLS-1$
}
// see if there are more options
menuNode = menuNode.getNextSibling();
}
}
return map;
}
示例4: parseXmlForAdditionalClasses
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
public void parseXmlForAdditionalClasses() throws KettleException{
try {
Properties sysprops = System.getProperties();
String strActPath = sysprops.getProperty("user.dir");
Document dom = XMLHandler.loadXMLFile(strActPath + "/plugins/steps/ScriptValues_mod/plugin.xml");
Node stepnode = dom.getDocumentElement();
Node libraries = XMLHandler.getSubNode(stepnode, "js_libraries");
int nbOfLibs = XMLHandler.countNodes(libraries, "js_lib");
additionalClasses = new ScriptAddClasses[nbOfLibs];
for(int i=0;i<nbOfLibs;i++){
Node fnode = XMLHandler.getSubNodeByNr(libraries, "js_lib", i);
String strJarName = XMLHandler.getTagAttribute(fnode, "name");
String strClassName =XMLHandler.getTagAttribute(fnode, "classname");
String strJSName = XMLHandler.getTagAttribute(fnode, "js_name");
Class<?> addClass = LoadAdditionalClass(strActPath + "/plugins/steps/ScriptValues_mod/"+ strJarName,strClassName);
Object addObject = addClass.newInstance();
additionalClasses[i] = new ScriptAddClasses(addClass, addObject, strJSName);
}
}catch(Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "ScriptMeta.Exception.UnableToParseXMLforAdditionalClasses"), e);
}
}
示例5: parseXmlForAdditionalClasses
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
public void parseXmlForAdditionalClasses() throws KettleException{
try {
Properties sysprops = System.getProperties();
String strActPath = sysprops.getProperty("user.dir");
Document dom = XMLHandler.loadXMLFile(strActPath + "/plugins/steps/ScriptValues_mod/plugin.xml");
Node stepnode = dom.getDocumentElement();
Node libraries = XMLHandler.getSubNode(stepnode, "js_libraries");
int nbOfLibs = XMLHandler.countNodes(libraries, "js_lib");
additionalClasses = new ScriptValuesAddClasses[nbOfLibs];
for(int i=0;i<nbOfLibs;i++){
Node fnode = XMLHandler.getSubNodeByNr(libraries, "js_lib", i);
String strJarName = XMLHandler.getTagAttribute(fnode, "name");
String strClassName =XMLHandler.getTagAttribute(fnode, "classname");
String strJSName = XMLHandler.getTagAttribute(fnode, "js_name");
Class<?> addClass = LoadAdditionalClass(strActPath + "/plugins/steps/ScriptValues_mod/"+ strJarName,strClassName);
Object addObject = addClass.newInstance();
additionalClasses[i] = new ScriptValuesAddClasses(addClass, addObject, strJSName);
}
}catch(Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "ScriptValuesMetaMod.Exception.UnableToParseXMLforAdditionalClasses"), e);
}
}
示例6: loadStepAttributes
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
protected void loadStepAttributes() throws KettleException {
try {
InputStream inputStream = getClass().getResourceAsStream(STEP_ATTRIBUTES_FILE);
if (inputStream!=null) {
Document document = XMLHandler.loadXMLFile(inputStream);
Node attrsNode = XMLHandler.getSubNode(document, "attributes");
List<Node> nodes = XMLHandler.getNodes(attrsNode, "attribute");
attributes = new ArrayList<KettleAttributeInterface>();
for (Node node : nodes) {
String key = XMLHandler.getTagAttribute(node, "id");
String xmlCode = XMLHandler.getTagValue(node, "xmlcode");
String repCode = XMLHandler.getTagValue(node, "repcode");
String description = XMLHandler.getTagValue(node, "description");
String tooltip = XMLHandler.getTagValue(node, "tooltip");
int valueType = ValueMeta.getType( XMLHandler.getTagValue(node, "valuetype") );
String parentId = XMLHandler.getTagValue(node, "parentid");
KettleAttribute attribute = new KettleAttribute(key, xmlCode, repCode, description, tooltip, valueType, findParent(attributes, parentId));
attributes.add(attribute);
}
}
} catch(Exception e) {
throw new KettleException("Unable to load file "+STEP_ATTRIBUTES_FILE, e);
}
}
示例7: readPluginLocale
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
private Map<String, String> readPluginLocale(Node pluginNode, String localizedTag, String translationTag) {
Map<String, String> map = new Hashtable<String, String>();
Node locTipsNode = XMLHandler.getSubNode(pluginNode, localizedTag);
int nrLocTips = XMLHandler.countNodes(locTipsNode, translationTag);
for (int j=0 ; j < nrLocTips; j++)
{
Node locTipNode = XMLHandler.getSubNodeByNr(locTipsNode, translationTag, j);
if (locTipNode!=null) {
String locale = XMLHandler.getTagAttribute(locTipNode, "locale");
String locTip = XMLHandler.getNodeValue(locTipNode);
if (!Const.isEmpty(locale) && !Const.isEmpty(locTip))
{
map.put(locale.toLowerCase(), locTip);
}
}
}
return map;
}
示例8: createMenuBarFromXul
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
public static MenuBar createMenuBarFromXul( Document doc, Shell shell, Messages xulMessages ) {
NodeList list = doc.getElementsByTagName( "menubar" ); //$NON-NLS-1$
if( list != null && list.getLength() > 0 ) {
MenuBar menuBar = new MenuBar( shell );
// we can only handle one menu bar
Node menubarNode = list.item( 0 );
// get the top level menus
Node menuNode = XMLHandler.getSubNode( menubarNode, "menu" ); //$NON-NLS-1$
while( menuNode != null ) {
if( "menu".equals( menuNode.getNodeName() ) ) { //$NON-NLS-1$
// create a top-level item
String id = XMLHandler.getTagAttribute( menuNode, "value" ); //$NON-NLS-1$
String name = XMLHandler.getTagAttribute( menuNode, "label" ); //$NON-NLS-1$
if( name == null ) {
name = getMenuLabel( menuNode );
}
name = localizeXulText( name, xulMessages );
String accessKey = XMLHandler.getTagAttribute( menuNode, "accesskey" ); //$NON-NLS-1$
Menu menu = new Menu(menuBar, name, id, accessKey );
// create a submenu if it exists
createMenuFromXul( menu, XMLHandler.getSubNode( menuNode, "menupopup" ), xulMessages ); //$NON-NLS-1$
}
// see if there are more options
menuNode = menuNode.getNextSibling();
}
return menuBar;
}
return null;
}
示例9: getTagOrAttribute
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
private String getTagOrAttribute(Node pluginNode, String tag) {
String string = XMLHandler.getTagValue(pluginNode, tag);
if (string==null) {
string = XMLHandler.getTagAttribute(pluginNode, tag); //$NON-NLS-1$
}
return string;
}
示例10: createToolbarFromXul
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
public static Toolbar createToolbarFromXul( Document doc, Composite parentComposite, Messages xulMessages, Object caller ) {
NodeList list = doc.getElementsByTagName( "toolbox" ); //$NON-NLS-1$
Toolbar toolbar = null;
if( list != null && list.getLength() > 0 ) {
// we can only handle one menu bar
Node toolboxNode = list.item( 0 );
// get the top level menus
Node toolbarNode = XMLHandler.getSubNode( toolboxNode, "toolbar" ); //$NON-NLS-1$
while( toolbarNode != null ) {
if( "toolbar".equals( toolbarNode.getNodeName() ) ) { //$NON-NLS-1$
// create a top-level item
String id = XMLHandler.getTagAttribute( toolbarNode, "id" ); //$NON-NLS-1$
String mode = XMLHandler.getTagAttribute( toolbarNode, "mode" ); //$NON-NLS-1$
toolbar = new Toolbar(parentComposite, id, null);
if( "full".equals( mode ) ) toolbar.setMode(Toolbar.MODE_FULL);
else if( "icons".equals( mode ) ) toolbar.setMode(Toolbar.MODE_ICONS);
else if( "text".equals( mode ) ) toolbar.setMode(Toolbar.MODE_TEXT);
Node buttonNode = toolbarNode.getFirstChild();
while( buttonNode != null ) {
if( "toolbarbutton".equals( buttonNode.getNodeName() ) ) { //$NON-NLS-1$
String value = XMLHandler.getTagAttribute( buttonNode, "value" ); //$NON-NLS-1$
String imagePath = XMLHandler.getTagAttribute( buttonNode, "image" ); //$NON-NLS-1$
String hint = XMLHandler.getTagAttribute( buttonNode, "tooltiptext" ); //$NON-NLS-1$
hint = localizeXulText( hint, xulMessages );
if (hint!=null) {
// Remove ampersands from tooltips. They work great on labels, not in tooltips
hint = Const.replace(hint, "&", "");
}
String label = XMLHandler.getTagAttribute( buttonNode, "label" ); //$NON-NLS-1$
label = localizeXulText( label, xulMessages );
ToolbarButton button = new ToolbarButton(parentComposite, value, toolbar);
button.setHint(hint);
button.setText(label);
button.setImage(GUIResource.getInstance().getImage(imagePath));
toolbar.register(button, value, null);
}
else if( "toolbarseparator".equals( buttonNode.getNodeName() ) ) { //$NON-NLS-1$
new ToolbarSeparator(parentComposite, toolbar);
}
buttonNode = buttonNode.getNextSibling();
}
}
// see if there are more options
toolbarNode = toolbarNode.getNextSibling();
}
return toolbar;
}
return null;
}
示例11: addLabelOccurrences
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
private void addLabelOccurrences(FileObject fileObject, NodeList nodeList,
String keyPrefix, String tag, String attribute,
String defaultPackage,
List<SourceCrawlerPackageException> packageExcpeptions)
throws Exception {
if (nodeList == null)
return;
TransformerFactory transformerFactory = TransformerFactory
.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
String labelString = null;
if (!Const.isEmpty(attribute)) {
labelString = XMLHandler.getTagAttribute(node, attribute);
} else if (!Const.isEmpty(tag)) {
labelString = XMLHandler.getTagValue(node, tag);
}
if (labelString != null && labelString.startsWith(keyPrefix)) {
String key = labelString.substring(1);
String messagesPackage = defaultPackage;
for (SourceCrawlerPackageException packageException : packageExcpeptions) {
if (key.startsWith(packageException.getStartsWith()))
messagesPackage = packageException.getPackageName();
}
StringWriter bodyXML = new StringWriter();
transformer.transform(new DOMSource(node), new StreamResult(
bodyXML));
String xml = bodyXML.getBuffer().toString();
KeyOccurrence keyOccurrence = new KeyOccurrence(fileObject,
messagesPackage, -1, -1, key, "?", xml);
if (!occurrences.contains(keyOccurrence)) {
occurrences.add(keyOccurrence);
}
}
}
}
示例12: addLabelOccurrences
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
private void addLabelOccurrences(FileObject fileObject, NodeList nodeList,
String keyPrefix, String tag, String attribute,
String defaultPackage,
List<SourceCrawlerPackageException> packageExcpeptions)
throws Exception {
if (nodeList == null)
return;
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
String labelString = null;
if (!Const.isEmpty(attribute)) {
labelString = XMLHandler.getTagAttribute(node, attribute);
} else if (!Const.isEmpty(tag)) {
labelString = XMLHandler.getTagValue(node, tag);
}
// TODO : Set the prefix in the right place
keyPrefix="$";
if (labelString != null && labelString.startsWith(keyPrefix)) {
String key = labelString.substring(1);
// TODO : maybe not the right place ...
// just removed ${} around the key
key=labelString.substring(2, labelString.length()-1).trim();
String messagesPackage = defaultPackage;
for (SourceCrawlerPackageException packageException : packageExcpeptions) {
if (key.startsWith(packageException.getStartsWith()))
messagesPackage = packageException.getPackageName();
}
StringWriter bodyXML = new StringWriter();
transformer.transform(new DOMSource(node), new StreamResult(bodyXML));
String xml = bodyXML.getBuffer().toString();
KeyOccurrence keyOccurrence = new KeyOccurrence(fileObject,messagesPackage, -1, -1, key, "?", xml);
if (!occurrences.contains(keyOccurrence)) {
occurrences.add(keyOccurrence);
}
}
}
}
示例13: registerPluginFromXmlResource
import org.pentaho.di.core.xml.XMLHandler; //导入方法依赖的package包/类
protected PluginInterface registerPluginFromXmlResource( Node pluginNode, String path, Class<? extends PluginTypeInterface> pluginType, boolean nativePlugin, URL pluginFolder) throws KettlePluginException {
try
{
String id = XMLHandler.getTagAttribute(pluginNode, "id"); //$NON-NLS-1$
String description = getTagOrAttribute(pluginNode, "description"); //$NON-NLS-1$
String iconfile = getTagOrAttribute(pluginNode, "iconfile"); //$NON-NLS-1$
String tooltip = getTagOrAttribute(pluginNode, "tooltip"); //$NON-NLS-1$
String category = getTagOrAttribute(pluginNode, "category"); //$NON-NLS-1$
String classname = getTagOrAttribute(pluginNode, "classname"); //$NON-NLS-1$
String errorHelpfile = getTagOrAttribute(pluginNode, "errorhelpfile"); //$NON-NLS-1$
Node libsnode = XMLHandler.getSubNode(pluginNode, "libraries"); //$NON-NLS-1$
int nrlibs = XMLHandler.countNodes(libsnode, "library"); //$NON-NLS-1$
List<String> jarFiles = new ArrayList<String>();
if( path != null ) {
for (int j = 0; j < nrlibs; j++)
{
Node libnode = XMLHandler.getSubNodeByNr(libsnode, "library", j); //$NON-NLS-1$
String jarfile = XMLHandler.getTagAttribute(libnode, "name"); //$NON-NLS-1$
jarFiles.add( new File(path + Const.FILE_SEPARATOR + jarfile).getAbsolutePath() );
}
}
// Localized categories, descriptions and tool tips
//
Map<String, String> localizedCategories = readPluginLocale(pluginNode, "localized_category", "category");
category = getAlternativeTranslation(category, localizedCategories);
Map<String, String> localizedDescriptions = readPluginLocale(pluginNode, "localized_description", "description");
description = getAlternativeTranslation(description, localizedDescriptions);
Map<String, String> localizedTooltips = readPluginLocale(pluginNode, "localized_tooltip", "tooltip");
tooltip = getAlternativeTranslation(tooltip, localizedTooltips);
String iconFilename = (path == null) ? iconfile : path + Const.FILE_SEPARATOR + iconfile;
String errorHelpFileFull = errorHelpfile;
if (!Const.isEmpty(errorHelpfile)) errorHelpFileFull = (path == null) ? errorHelpfile : path+Const.FILE_SEPARATOR+errorHelpfile;
Map<Class<?>, String> classMap = new HashMap<Class<?>, String>();
PluginMainClassType mainClassTypesAnnotation = pluginType.getAnnotation(PluginMainClassType.class);
classMap.put(mainClassTypesAnnotation.value(), classname);
// process annotated extra types
PluginExtraClassTypes classTypesAnnotation = pluginType.getAnnotation(PluginExtraClassTypes.class);
if(classTypesAnnotation != null){
for(int i=0; i< classTypesAnnotation.classTypes().length; i++){
Class<?> classType = classTypesAnnotation.classTypes()[i];
String className = getTagOrAttribute(pluginNode, classTypesAnnotation.xmlNodeNames()[i]); //$NON-NLS-1$
classMap.put(classType, className);
}
}
// process extra types added at runtime
Map<Class<?>, String> objectMap = getAdditionalRuntimeObjectTypes();
for(Map.Entry<Class<?>, String> entry : objectMap.entrySet()){
String clzName = getTagOrAttribute(pluginNode, entry.getValue()); //$NON-NLS-1$
classMap.put(entry.getKey(), clzName);
}
PluginInterface pluginInterface = new Plugin(id.split(","), pluginType, mainClassTypesAnnotation.value(), category, description, tooltip, iconFilename, false, nativePlugin, classMap, jarFiles, errorHelpFileFull, pluginFolder);
registry.registerPlugin(pluginType, pluginInterface);
return pluginInterface;
}
catch (Throwable e)
{
throw new KettlePluginException( BaseMessages.getString(PKG, "BasePluginType.RuntimeError.UnableToReadPluginXML.PLUGIN0001"), e); //$NON-NLS-1$
}
}