diff --git a/pmml-rexp/src/main/java/org/jpmml/rexp/BinaryTreeConverter.java b/pmml-rexp/src/main/java/org/jpmml/rexp/BinaryTreeConverter.java index 3a46a09..fe070fb 100644 --- a/pmml-rexp/src/main/java/org/jpmml/rexp/BinaryTreeConverter.java +++ b/pmml-rexp/src/main/java/org/jpmml/rexp/BinaryTreeConverter.java @@ -115,7 +115,7 @@ private void encodeResponse(S4Object responses, RExpEncoder encoder){ RExp targetVariable = variables.getElement(variableName); - RStringVector targetVariableClass = RExpUtil.getClassNames(targetVariable); + RStringVector targetVariableClass = targetVariable._class(); RStringVector targetCategories = levels.getStringElement(variableName); diff --git a/pmml-rexp/src/main/java/org/jpmml/rexp/ConverterFactory.java b/pmml-rexp/src/main/java/org/jpmml/rexp/ConverterFactory.java index 1582885..c82424b 100644 --- a/pmml-rexp/src/main/java/org/jpmml/rexp/ConverterFactory.java +++ b/pmml-rexp/src/main/java/org/jpmml/rexp/ConverterFactory.java @@ -37,7 +37,7 @@ protected ConverterFactory(){ } public Converter newConverter(R rexp){ - RStringVector classNames = RExpUtil.getClassNames(rexp); + RStringVector classNames = rexp._class(); for(String className : classNames){ Class> clazz = ConverterFactory.converters.get(className); diff --git a/pmml-rexp/src/main/java/org/jpmml/rexp/DecorationUtil.java b/pmml-rexp/src/main/java/org/jpmml/rexp/DecorationUtil.java index 653391f..b322586 100644 --- a/pmml-rexp/src/main/java/org/jpmml/rexp/DecorationUtil.java +++ b/pmml-rexp/src/main/java/org/jpmml/rexp/DecorationUtil.java @@ -65,7 +65,7 @@ public RVector getVectorElement(RGenericVector model, String name){ static private RuntimeException toDecorationException(RGenericVector model, String name, Exception e){ - RStringVector classNames = RExpUtil.getClassNames(model); + RStringVector classNames = model._class(); String className = classNames.getValue(0); diff --git a/pmml-rexp/src/main/java/org/jpmml/rexp/RExp.java b/pmml-rexp/src/main/java/org/jpmml/rexp/RExp.java index eeb011a..46bcf88 100644 --- a/pmml-rexp/src/main/java/org/jpmml/rexp/RExp.java +++ b/pmml-rexp/src/main/java/org/jpmml/rexp/RExp.java @@ -35,6 +35,10 @@ public void write(RDataOutput output) throws IOException { throw new UnsupportedOperationException(); } + public RStringVector _class(){ + return getStringAttribute("class"); + } + public RStringVector names(){ return getStringAttribute("names"); } diff --git a/pmml-rexp/src/main/java/org/jpmml/rexp/RExpUtil.java b/pmml-rexp/src/main/java/org/jpmml/rexp/RExpUtil.java index 11d3649..e1a10f5 100644 --- a/pmml-rexp/src/main/java/org/jpmml/rexp/RExpUtil.java +++ b/pmml-rexp/src/main/java/org/jpmml/rexp/RExpUtil.java @@ -65,13 +65,6 @@ public String getVectorType(Class clazz){ return vectorType; } - static - public RStringVector getClassNames(RExp rexp){ - RStringVector result = rexp.getStringAttribute("class"); - - return result; - } - static public String makeName(String string){ StringBuilder sb = new StringBuilder(); diff --git a/pmml-rexp/src/test/java/org/jpmml/rexp/SerializeTest.java b/pmml-rexp/src/test/java/org/jpmml/rexp/SerializeTest.java index eb8c6e6..3bf3d9b 100644 --- a/pmml-rexp/src/test/java/org/jpmml/rexp/SerializeTest.java +++ b/pmml-rexp/src/test/java/org/jpmml/rexp/SerializeTest.java @@ -129,7 +129,7 @@ private void checkDataFrame(RGenericVector dataFrame){ assertTrue(dataFrame.hasAttribute("names")); assertTrue(dataFrame.hasAttribute("row.names")); - assertEquals(Arrays.asList("data.frame"), (dataFrame.getStringAttribute("class")).getValues()); + assertEquals(Arrays.asList("data.frame"), (dataFrame._class()).getValues()); assertEquals(5, dataFrame.size());