/** * Adds the internal representation of attr, to the index object. */ private void addInternalAttribute(StandaloneWWIndexData index, Attribute<?> attr) { String name = attr.getName(); if (attr instanceof NonIndexedAttribute){ // NOTE: Only String supported so far. NonIndexStringAttribute str = (NonIndexStringAttribute) attr; int attrid = getAttrDefs().getAttrId(name, str.getClass()); index.setNonIndexString(attrid, str.getValue()); } else { IAttribute attribute = getIAttribute(name, attr); if (attribute==null){ log.error("null attr: " + attr.toString()); attribute = getIAttribute(name, attr); // was for debugging only } index.getAttributeMap().putAttr(attribute); } }
@Override synchronized public String convertToInternal(int attrid, Object object) throws AttributeException { NonIndexStringAttribute attr = (NonIndexStringAttribute) object; String postcode = attr.getValue(); GeoInformation result = converter.lookupShort(postcode); if (result == null) { result = converter.lookupFull(postcode); } if (result == null){ throw new AttributeException("Unable to lookup postcode for: " + attr.getName() + "=" + postcode); } return result.getTown(); }
/** * Perform the search conversion for this attr, if it exists */ private void deriveSearchAttrs(CardinalAttributeMap<IAttribute> attrs, String name, Attribute<?> value) { SearchConverter<? extends IAttribute> conversion = searchConversions.get(name); if (conversion == null) { return; } int attrId = getAttrDefs().getAttrId( conversion.getDerivedAttrName(), conversion.getInboundClass() ); String str; if (value instanceof NonIndexStringAttribute){ str = ((NonIndexStringAttribute)value).getValue(); } else { str = ((UnspecifiedTypeAttribute)value).getValue(); } IAttribute internal = conversion.convertStringToInternal(attrId, str); attrs.put(attrId, internal); }
@Override synchronized public EcefVector convertToInternal(int attrid, Object object) throws AttributeException { NonIndexStringAttribute attr = (NonIndexStringAttribute) object; String postcode = attr.getValue(); GeoInformation result = converter.lookupShort(postcode); if (result == null) { result = converter.lookupFull(postcode); } if (result == null){ throw new AttributeException("Unable to lookup postcode for: " + attr.getName() + "=" + postcode); } return EcefVector.fromDegs(attrid, result.getLatitude(), result.getLongitude()); }