java - Working out a Google App engine entity's property data type -
i have entity - i'm trying determine type of properties - in google app engine's internal data-types preferred (as opposed java data types).
below code simplified. in reality not know entity's properties or else it.
final datastoreservice dss = datastoreservicefactory.getdatastoreservice(); final query query = new query("person"); final preparedquery pq = dss.prepare(query); (entity entity : pq.asiterable()) { final object property = entity.getproperty("some_property"); // here want determine data type 'property' represents - gae-wise. }
in app engine's java code i've found hints:
datatypetranslator datatypetranslator.typemap (internal private member) property.meaning.gd_phonenumber
i'm unable link need - sort of reflection.
i wish able this:
entity.getpropertytype("some_property");
does know better?
datatypetranslator source code here
edit #1: << ingore one. it's me put these postfixes (i confused doc).
here's more important info i've found.
i'm getting in eclipse' tool-tip mini-window when point on entity (one fetched datastore).
datastore seems send (this payload) raw text nice, maybe i'll have parse (but, how code lol).
pay attention types in here, it's written plain simple.
here is:
<entity [bird(9)]: int64type:44rmna4kc2g23i9brlupps74ir#int64type = 1234567890 string:igt7qvk9p89nc3gjqn9s3jq69c = 7tns1l48vpttq5ff47i3jlq3f9 phonenumber:auih50aecl574ud23v9h4rfvt1#phonenumbertype = 03-6491234 date:k1qstkn9np0mpb6fp41cj6i3am = wed jul 20 23:03:13 utc 2011 >
for example, property named string:igt7qvk9p89nc3gjqn9s3jq69c
has value of 7tns1l48vpttq5ff47i3jlq3f9
, doesn't tell type. property date:k1qstkn9np0mpb6fp41cj6i3am
.
property named int64type:44rmna4kc2g23i9brlupps74ir
has value of "1234567890" , here strictly mentions data type of "int64type".
i'm searching too.
it's bit of hack, @ least output includes type (without needing secret decoder ring). code different:
query allusersentityquery = new query(); allusersentityquery.setancestor(userkey); (final entity entity : datastore.prepare(allusersentityquery).asiterable()) { map<string, object> properties = entity.getproperties(); string[] propertynames = properties.keyset().toarray( new string[properties.size()]); for(final string propertyname : propertynames) { // propertynames string contains // "com.google.appengine.api.datastore.postaladdress" if postal address } }
there seems no documents determining property types here.
Comments
Post a Comment