Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.w3c.dom.Element; public class Main { /** * Extracts a list of integer values from the specified attribute. * @param element the element to fetch the integer list from * @param attributeName the name of the attribute containing the integer list * @return a list of integer values from the specified attribute */ public static List<Integer> getIntegerListAttribute(Element element, String attributeName) { String intListString = element.getAttribute(attributeName); if (intListString == null || intListString.length() == 0) { return Collections.emptyList(); } String[] intStrings = intListString.split(" "); //$NON-NLS-1$ List<Integer> intValues = new ArrayList<Integer>(intStrings.length); for (String intString : intStrings) { Integer intValue = Integer.valueOf(intString); intValues.add(intValue); } return intValues; } }