Simplified the HistoryService - TextType was removed.

cusax-fix
Alexander Pelov 20 years ago
parent 1bf1713975
commit 9ac87e315a

@ -16,7 +16,6 @@
import net.java.sip.communicator.service.history.History;
import net.java.sip.communicator.service.history.HistoryID;
import net.java.sip.communicator.service.history.records.HistoryRecordStructure;
import net.java.sip.communicator.service.history.records.TextType;
import net.java.sip.communicator.util.EnumerationBase;
import net.java.sip.communicator.util.xml.XMLUtils;
@ -80,13 +79,10 @@ private Element createStructureTag(Document doc,
{
Element structure = doc.createElement("structure");
String[] propertyNames = recordStructure.getPropertyNames();
TextType[] propertyTypes = recordStructure.getValueTypes();
int count = recordStructure.getPropertyCount();
for(int i = 0; i < count; i++) {
Element property = doc.createElement("property");
property.setAttribute("name", propertyNames[i]);
property.setAttribute("type", propertyTypes[i].toString());
property.setAttribute("name", propertyNames[i]);
structure.appendChild(property);
}
@ -160,30 +156,19 @@ private HistoryRecordStructure loadStructure(Node root)
{
Element parameter = (Element) node;
String paramName = parameter.getAttribute("name");
String paramType = parameter.getAttribute("type");
if(paramName == null) {
continue;
}
TextType type = (TextType)EnumerationBase.fromString(
TextType.class, paramType);
if(type == null) {
type = HistoryRecordStructure.DEFAULT_TEXT_TYPE;
}
propertyNames.add(paramName);
propertyTypes.add(type);
}
}
String[] names = new String[propertyNames.size()];
TextType[] types = new TextType[propertyTypes.size()];
String[] names = new String[propertyNames.size()];
propertyNames.toArray(names);
propertyTypes.toArray(types);
return new HistoryRecordStructure(names, types);
return new HistoryRecordStructure(names);
}
private HistoryID loadID(Node parent) throws ParseException {

@ -13,16 +13,13 @@
*/
public class HistoryRecordStructure {
public static final TextType DEFAULT_TEXT_TYPE = TextType.LONG;
private String[] propertyNames;
private TextType[] valueTypes;
/**
* Creates an entry structure object used to define the shape of the data
* stored in the history. All valueTypes are set to TextType.LONG.
* stored in the history.
*
* Note that the property values are not unique, i.e. a single property
* Note that the property names are not unique, i.e. a single property
* may have 0, 1 or more values.
*
* @param propertyNames
@ -31,44 +28,13 @@ public HistoryRecordStructure(String[] propertyNames) {
Assert.assertNonNull(propertyNames, "Parameter propertyNames should be non-null.");
this.propertyNames = new String[propertyNames.length];
System.arraycopy(propertyNames, 0, this.propertyNames, 0, this.propertyNames.length);
this.valueTypes = new TextType[this.propertyNames.length];
for(int i = 0; i < this.valueTypes.length; i++) {
this.valueTypes[i] = HistoryRecordStructure.DEFAULT_TEXT_TYPE;
}
}
/**
* Creates an entry structure object used to define the shape of the data
* stored in the history.
*
* Note that the property values are not unique, i.e. a single property
* may have 0, 1 or more values.
*
* @param propertyNames
* @param valueTypes
*/
public HistoryRecordStructure(String[] propertyNames, TextType[] valueTypes) {
Assert.assertNonNull(propertyNames, "Parameter propertyNames should be non-null.");
Assert.assertNonNull(valueTypes, "Parameter valueTypes should be non-null.");
Assert.assertTrue(propertyNames.length == valueTypes.length,
"The length of the propertyNames and valueTypes should be equal.");
this.propertyNames = new String[propertyNames.length];
this.valueTypes = new TextType[valueTypes.length];
System.arraycopy(propertyNames, 0, this.propertyNames, 0, this.propertyNames.length);
System.arraycopy(valueTypes, 0, this.valueTypes, 0, this.valueTypes.length);
}
public String[] getPropertyNames() {
return this.propertyNames;
}
public TextType[] getValueTypes() {
return this.valueTypes;
}
public int getPropertyCount() {
return this.propertyNames.length;
}

@ -1,23 +0,0 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.history.records;
import net.java.sip.communicator.util.EnumerationBase;
/**
* @author Alexander Pelov
*/
public final class TextType extends EnumerationBase {
public static final TextType SHORT = new TextType("SHORT");
public static final TextType LONG = new TextType("LONG");
protected TextType(String description) {
super(description);
}
}
Loading…
Cancel
Save