App Engine - 为什么有PhoneNumber,Link,Rating等类? [英] App Engine - why are there PhoneNumber, Link, Rating etc classes?

查看:133
本文介绍了App Engine - 为什么有PhoneNumber,Link,Rating等类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没有找到任何App Engine类存在的理由。有一个PhoneNumber,一个Link,一个PostalAddress,一个GeoPt,一个评级等等。为什么这些都会得到特殊待遇?他们似乎没有任何智慧 - 例如地理搜索。我知道Link比String属性有更多的空间,但剩下的部分?

请参阅:
http://code.google.com/appengine/docs/java/datastore/dataclasses.html

解决方案

这些类型是'语义'类型。它们出现在Java API中以与Python API保持一致。在Python API中,它们定义了与.to_xml()方法有关的特殊行为 - 例如,PhoneNumberProperty像这样序列化:

 <$ c $ < gd:phoneNumber> 12345-678< / gd:phoneNumber>< / property> 


I haven't found any reason for the existence of a few of the App Engine classes. There's a PhoneNumber, a Link, a PostalAddress, a GeoPt, a Rating, etc. Why are these given special treatment? They don't seem to have any smarts - e.g. geo searching. I know Link has more space than a String property, but the rest?

See: http://code.google.com/appengine/docs/java/datastore/dataclasses.html

解决方案

Those types are 'semantic' types. They're present in the Java API for parity with the Python API. In the Python API, they define special behaviour with regards to the .to_xml() method - for example, a PhoneNumberProperty serializes like this:

<property name="foo" type="gd:phonenumber"><gd:phoneNumber>12345-678</gd:phoneNumber></property>

这篇关于App Engine - 为什么有PhoneNumber,Link,Rating等类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆