From 003d73fd7df1e6eb736bad0b84e63f9b16d87fde Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Tue, 30 Mar 2004 02:33:28 +0000 Subject: [PATCH] Adds #getValue(String) to the inner class Row which allows to hide the inner class Field git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2266 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/smackx/ReportedData.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/source/org/jivesoftware/smackx/ReportedData.java b/source/org/jivesoftware/smackx/ReportedData.java index 3d7a28dc7..be4ece5e3 100644 --- a/source/org/jivesoftware/smackx/ReportedData.java +++ b/source/org/jivesoftware/smackx/ReportedData.java @@ -227,17 +227,33 @@ public class ReportedData { this.fields = fields; } + /** + * Returns the value of the field whose variable matches the requested variable. + * + * @param variable the variable to match. + * @return the value of the field whose variable matches the requested variable. + */ + public String getValue(String variable) { + for(Iterator it=getFields();it.hasNext();) { + Field field = (Field) it.next(); + if (variable.equals(field.getVariable())) { + return field.getValue(); + } + } + return null; + } + /** * Returns the fields that define the data that goes with the item. * * @return the fields that define the data that goes with the item. */ - public Iterator getFields() { + private Iterator getFields() { return Collections.unmodifiableList(new ArrayList(fields)).iterator(); } } - public static class Field { + private static class Field { private String variable; private String value;