weka.core.pmml.Array Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of weka-stable Show documentation
Show all versions of weka-stable Show documentation
The Waikato Environment for Knowledge Analysis (WEKA), a machine
learning workbench. This is the stable version. Apart from bugfixes, this version
does not receive any other updates.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/*
* Array.java
* Copyright (C) 2009-2012 University of Waikato, Hamilton, New Zealand
*
*/
package weka.core.pmml;
import java.io.Serializable;
import java.io.StreamTokenizer;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import org.w3c.dom.Element;
/**
* Class for encapsulating a PMML Array element.
*
* @author Mark Hall (mhall{[at]}pentaho{[dot]}com)
* @version $Revision: 10203 $
*/
public class Array implements Serializable {
/** ID added to avoid warning */
private static final long serialVersionUID = 4286234448957826177L;
/**
* Utility method to check if an XML element is an array.
*
* @param arrayE the XML element to check
* @return returns true if the XML element is an array
*/
public static boolean isArray(Element arrayE) {
String name = arrayE.getTagName();
if (name.equals("Array") || name.equals("NUM-ARRAY")
|| name.equals("INT-ARRAY") || name.equals("REAL-ARRAY")
|| name.equals("STRING-ARRAY") || isSparseArray(arrayE)) {
return true;
}
return false;
}
/**
* Utility method to check if an XML element is a sparse array.
*
* @param arrayE the XML element to check.
* @return true if the XML element is a sparse array.
*/
private static boolean isSparseArray(Element arrayE) {
String name = arrayE.getTagName();
if (name.equals("INT-SparseArray") || name.equals("REAL-SparseArray")) {
return true;
}
return false;
}
public static Array create(List