- 浏览: 785672 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (360)
- Java (101)
- JPA/Hibernate (10)
- Spring (14)
- Flex/BlazeDS (37)
- Database (30)
- Lucene/Solr/Nutch (0)
- Maven/Ant (25)
- CXF/WebService (3)
- RPC/RMI/SOAP/WSDL (1)
- REST (6)
- TDD/BDD/JUnit (1)
- Servlet/JSP (2)
- AI/MachineLearning (3)
- Resource (1)
- 字符编码 (2)
- OOA/OOPS/UML (5)
- DesignPattern (8)
- 算法与数据结构 (11)
- Web&App Server (13)
- 并发&异步&无阻塞 (7)
- Entertainment (4)
- JavaScript/ExtJS (45)
- CodeStyle&Quality (1)
- svn/git/perforce (8)
- JSON (2)
- JavaScriptTesting (4)
- Others (6)
- RegularExpression (2)
- Linux/Windows (12)
- Protocal (2)
- Celebrities (1)
- Interview (1)
- 计算机语言 (1)
- English (2)
- Eclipse (5)
- TimeZone/时区 (1)
- Finance (1)
- 信息安全 (1)
- JMS/MQ (2)
- XSD/XML/DTD (3)
- Android (4)
- 投资 (3)
- Distribution (3)
- Excel (1)
最新评论
-
qdujunjie:
如果把m换成具体的数字,比如4或者5,会让读者更明白
m阶B树中“阶”的含义 -
java-admin:
不错,加油,多写点文章
关于Extjs的mixins和plugin -
xiehuaidong880827:
你好,我用sencha cmd打包完本地工程后,把app.js ...
ExtJS使用Sencha Cmd合并javascript文件为一个文件 -
KIWIFLY:
lwpan 写道inverse = "true&qu ...
Hibernate中什么时候使用inverse=true -
luedipiaofeng:
good
消除IE stop running this script弹出框
1. Be careful when defining uid property in your class
if you defined a uid property in your class (in regardless of its type, no matter what type it is), you will certainly find something wrong in your application soon, such as you cannot select some rows in List control and nodes in Tree control, why do we have this kind of strange issue when we don’t see any compiler error and runtime error, the reason is because flex data provider controls use a unique identifier (UID) to track data items, flex can automatically create and manage UIDs, but if you own class has uid property, flex will use the class defined uid, when the value of uid property in your object is not unique, then you will get above described strange issue.
By the way, you can use logger. debug ("selected object's uid:"+UIDUtil.getUID(selectedObject)); to check the uid value of your selected object.
Please see the following section for more details about uid in flex.
2. Data providers and the uid property
Flex data provider controls use a unique identifier (UID) to track data items. Flex can automatically create and manage UIDs. However, there are circumstances when you must supply your own uid property by implementing the IUID interface, and there are circumstances when supplying your own uid property improves processing efficiency.
Because the Object and Array classes are dynamic, you normally do not do anything special for data objects whose items belong to these classes. However, you should consider implementing the IUID if your data object items belong to custom classes that you define.
Note: When Flex creates a UID for an object, such as an item in an ArrayCollection, it adds the UID as an mx_internal_uid property of the item. Flex creates mx_internal_uid properties for any objects that are dynamic and do not have bindable properties. To avoid having Flex create mx_internal_uid properties, the object class should do any of the following things: have at least one property with a [Bindable] metadata tag; implement the IUID interface; or have a uid property with a value.
If Flex must consider two or more different objects to be identical, the objects must implement the IUID interface so that you can assign the same uid value to multiple objects. A typical case where you must implement the IUID interface is an application that uses paged collections. As the cursor moves through the collection, a particular item might be pulled down from the server and released from memory repeatedly. Every time the item is pulled into memory, a new object is created to represent the item. If you need to compare items for equality, Flex should consider all objects that represent the same item to be the same "thing."
More common than the case where you must implement the IUID interface is the case where you can improve processing efficiency by doing so. As a general rule, you do not implement the IUID interface if the data provider elements are members of dynamic classes. Flex can automatically create a uid property for these classes. There is still some inefficiency, however, so you might consider implementing the IUID interface if processing efficiency is particularly important.
In all other cases, Flex uses the Dictionary mechanism to manage the uid, which might not be as efficient as supplying your own UID.
The IUID interface contains a single property, uid, which is a unique identifier for the class member, and no methods. Flex provides a UIDUtil class that uses a pseudo-random-number generator to create an identifier that conforms to the standard GUID format. Although this identifier is not guaranteed to be universally unique, it should be unique among all members of your class. To implement a class that uses the UIDUtil class, such as a Person class that has fields for a first name, last name, and ID, you can use the following pattern:
package {
import mx.core.IUID;
import mx.utils.UIDUtil;
[Bindable]
public class Person implements IUID {
public var id:String;
public var firstName:String;
public var lastName:String;
private var _uid:String;
public function Person() {
_uid = UIDUtil.createUID();
}
public function get uid():String {
return _uid;
}
public function set uid(value: String):void {
// Do nothing, the constructor created the uid.
}
}
}
You do not need to use the UIDUtil class in a case where the objects contain a uniquely-identifying field such as an employee ID. In this case, you can use the person's ID as the uid property, because the uid property values uniquely identify the object only in the data provider. The following example implements this approach:
package
{
import mx.core.IUID;
[Bindable]
public class Person implements IUID {
public var employee_id:String;
public var firstName:String;
public var lastName:String;
public function get uid(): String {
return employee_id;
}
public function set uid(value: String): void {
employee_id=value;
}
}
}
Note: Object cloning does not manage or have a relationship with UIDs, so if you clone something that has an internal UID you must also change that internal UID. UIDs are stored on mx_internal_uid only for dynamic Objects. Instances of data classes that implement IUID store their UIDs in a uid property, so that is the property that must be changed after cloning.
3. Some guys who suffering from this problem
This has cost me a lot of time. If you implement a custom ValueObject which has a public property called uid (which was actually an user id in my app) and all of the items in the list have the same user id this will lead into serious problems. There should be at least a compiler warning or something that assigning uid can lead to problems if it isn't unique for all items. I searched about 2 hours for this entry.
An alternative to implementing iuid in order to have multiple objects as equal, is to check for the existence of an object in memory before instantiating it. A simple factory method that updates instead of creates when appropriate will do the job. Often a primary key for the database table will serve the purpose to identify the equal object.
It might be useful to use a database primary key as a light weight iuid, but I have not yet tried this because the value of my primary keys change from a negative number to a positive one when the row is inserted in the database.
if you defined a uid property in your class (in regardless of its type, no matter what type it is), you will certainly find something wrong in your application soon, such as you cannot select some rows in List control and nodes in Tree control, why do we have this kind of strange issue when we don’t see any compiler error and runtime error, the reason is because flex data provider controls use a unique identifier (UID) to track data items, flex can automatically create and manage UIDs, but if you own class has uid property, flex will use the class defined uid, when the value of uid property in your object is not unique, then you will get above described strange issue.
By the way, you can use logger. debug ("selected object's uid:"+UIDUtil.getUID(selectedObject)); to check the uid value of your selected object.
Please see the following section for more details about uid in flex.
2. Data providers and the uid property
Flex data provider controls use a unique identifier (UID) to track data items. Flex can automatically create and manage UIDs. However, there are circumstances when you must supply your own uid property by implementing the IUID interface, and there are circumstances when supplying your own uid property improves processing efficiency.
Because the Object and Array classes are dynamic, you normally do not do anything special for data objects whose items belong to these classes. However, you should consider implementing the IUID if your data object items belong to custom classes that you define.
Note: When Flex creates a UID for an object, such as an item in an ArrayCollection, it adds the UID as an mx_internal_uid property of the item. Flex creates mx_internal_uid properties for any objects that are dynamic and do not have bindable properties. To avoid having Flex create mx_internal_uid properties, the object class should do any of the following things: have at least one property with a [Bindable] metadata tag; implement the IUID interface; or have a uid property with a value.
If Flex must consider two or more different objects to be identical, the objects must implement the IUID interface so that you can assign the same uid value to multiple objects. A typical case where you must implement the IUID interface is an application that uses paged collections. As the cursor moves through the collection, a particular item might be pulled down from the server and released from memory repeatedly. Every time the item is pulled into memory, a new object is created to represent the item. If you need to compare items for equality, Flex should consider all objects that represent the same item to be the same "thing."
More common than the case where you must implement the IUID interface is the case where you can improve processing efficiency by doing so. As a general rule, you do not implement the IUID interface if the data provider elements are members of dynamic classes. Flex can automatically create a uid property for these classes. There is still some inefficiency, however, so you might consider implementing the IUID interface if processing efficiency is particularly important.
In all other cases, Flex uses the Dictionary mechanism to manage the uid, which might not be as efficient as supplying your own UID.
The IUID interface contains a single property, uid, which is a unique identifier for the class member, and no methods. Flex provides a UIDUtil class that uses a pseudo-random-number generator to create an identifier that conforms to the standard GUID format. Although this identifier is not guaranteed to be universally unique, it should be unique among all members of your class. To implement a class that uses the UIDUtil class, such as a Person class that has fields for a first name, last name, and ID, you can use the following pattern:
package {
import mx.core.IUID;
import mx.utils.UIDUtil;
[Bindable]
public class Person implements IUID {
public var id:String;
public var firstName:String;
public var lastName:String;
private var _uid:String;
public function Person() {
_uid = UIDUtil.createUID();
}
public function get uid():String {
return _uid;
}
public function set uid(value: String):void {
// Do nothing, the constructor created the uid.
}
}
}
You do not need to use the UIDUtil class in a case where the objects contain a uniquely-identifying field such as an employee ID. In this case, you can use the person's ID as the uid property, because the uid property values uniquely identify the object only in the data provider. The following example implements this approach:
package
{
import mx.core.IUID;
[Bindable]
public class Person implements IUID {
public var employee_id:String;
public var firstName:String;
public var lastName:String;
public function get uid(): String {
return employee_id;
}
public function set uid(value: String): void {
employee_id=value;
}
}
}
Note: Object cloning does not manage or have a relationship with UIDs, so if you clone something that has an internal UID you must also change that internal UID. UIDs are stored on mx_internal_uid only for dynamic Objects. Instances of data classes that implement IUID store their UIDs in a uid property, so that is the property that must be changed after cloning.
3. Some guys who suffering from this problem
This has cost me a lot of time. If you implement a custom ValueObject which has a public property called uid (which was actually an user id in my app) and all of the items in the list have the same user id this will lead into serious problems. There should be at least a compiler warning or something that assigning uid can lead to problems if it isn't unique for all items. I searched about 2 hours for this entry.
An alternative to implementing iuid in order to have multiple objects as equal, is to check for the existence of an object in memory before instantiating it. A simple factory method that updates instead of creates when appropriate will do the job. Often a primary key for the database table will serve the purpose to identify the equal object.
It might be useful to use a database primary key as a light weight iuid, but I have not yet tried this because the value of my primary keys change from a negative number to a positive one when the row is inserted in the database.
发表评论
-
Panel高度为0但里面的组件依旧显示
2013-04-24 14:34 1084解决办法: 把Panel中的内容组件用<s:Scroll ... -
约束布局constraint layout
2013-03-01 14:02 1791约束布局constraint layout要点: 1)只有支持 ... -
根据屏幕分辨率动态调整组件大小
2013-02-22 17:34 1518将代码写在组件的preInitialize事件监听器里面 简化 ... -
设置Flex组件的尺寸大小
2013-02-21 16:17 1533深红色部分标明了需注意的地方 另外要注意组件和容器的生命周 ... -
Flex minWidth minHeight
2013-02-04 16:17 1519minWidth 这个值并不是给组件自己用的,而是给组件的父容 ... -
ActionScript遍历绑定(BindProperty,BindSetter,ChangeWatcher)
2013-02-01 10:11 2446注意: 为防止内存益处,记得调用watcherInstance ... -
Flex程序适应不同屏幕尺寸和分辨率(滚动条)
2013-01-31 15:02 9763FlashBuilder编译后自动生成的xx.html里面定义 ... -
FlexContext, FlexClient,FlexSession
2013-01-15 15:05 2372使用了BlazeDS后,可以从FlexContext中获取一系 ... -
防止RemoteObject批处理AMF消息
2013-01-14 17:01 1256问题描述: 如果你在短时内调用同一个java对象上的两个方法, ... -
自动检测http和https的RemoteObject
2013-01-13 10:30 1735package { import util.Bro ... -
flex浏览器相关辅组类
2012-12-06 13:39 1250package util { import flash. ... -
Flex可变参数带来的问题
2012-12-06 13:34 1489当你在flex的方法中用了可变参数后,你会发现这些参数传到ja ... -
flex如何通过类名称实例化对象
2012-11-30 13:52 2729Getting the class from an objec ... -
flexlib的treeGrid用法
2012-11-30 13:46 1269为了使用treeGrid,通常你需要定义自己的DataDesc ... -
自定义flex tree的DataDescriptor
2012-11-30 13:42 1406public class EnvironmentDataDes ... -
关于Boolean类型在flex与java中间传递的问题
2012-11-30 13:38 1253/** *为简化,只列举两个字段 */ publi ... -
给Flex的Tree赋值方式(XML和ArrayCollection)
2012-11-30 09:33 40221)方式一,mxml内嵌xml数据赋值方式,Embedded ... -
Custom Alert
2012-11-26 19:21 0<?xml version="1.0&qu ... -
Flex服务端分页
2012-11-14 17:00 1051Structure: model event ... -
Flex可携带数据的Aler组件(DataCarriableAlert)
2012-11-14 16:52 1311package component.alert { ...
相关推荐
Deep Visual Analogy-Making.pdf
全英文的魔电书,对留学生比较有帮助,在ccebook下载的不知各位大侠赏不赏脸。。。
is fi rst illustrated through real-life analogy. Corresponding Java language constructs are introduced in an integrated fashion to demonstrate the programming required to simulate the real-world ...
这是论文Visual Attribute Transfer through Deep Image Analogy的原文,内含有小编本人的理解与注释,谨以此分享个人经验和向广大大牛请教,如有错误,请不吝指出,万分感谢!
类比日志查看器 日志查看器,可以解析日志文件并流式传输C#,Python,Java和其他应用程序的日志。 您还可以实现自己的解析器或请求为其他日志添加新的解析器内容一般的类比日志查看器是Windows操作系统的多用途日志...
使用python实现的patchmatch算法,该代码主要实现补丁匹配算法,有两个patchmatch代码:PatchMatch.py??和PatchMatch_Bidirectional.py。最后一个用于代码DeepImageAnalogy
and an analogy to Al, we estimate the coupling constant to be of order 1. Together with high phonon frequencies, which we estimate via zone-center frozen phonon calculations to be between 300 and 700 ...
A Generic Framework for Efficient 2-D and 3-D Facial Expression Analogy
一个基于场景的环境,用于使用Csound修补程序,VST插件以及各种本机DSP和GUI元素来创建和执行实时电子作品。
纽伊姆 (NUI) 梅努斯大学源代码。 2014 年 12 月 12 日 ... ROS 生成和 ROS 评估工具包含在各自的文件夹中。 请使用 GenerateROS.html 查找 GenerateROS 程序的相关帮助文件和 ROS 评估工具的 rosat.html。
词类比 话题 给定三个词a,b和c,我们将必须生成下一个词d,以使a和b之间的关系与c和d之间的关系相同。 结果 这是单词嵌入的一些例子 学分 1.该存储库基于设置,。 2.杰弗里·彭宁顿(Jeffrey Pennington),理查德...
该项目是Deep Image Analogy的Python实现,基于pytorch
Analogy Log服务器支持以下实时数据: Windows事件日志(可在服务器设置中配置)任何实现Proto文件的gRPC客户端(目前已经完全实现了C#,Python和JAVA(Poc)客户端)存在以下模块:努吉特版本描述主要类比日志...
使用直方图类比进行深层色彩转移 图:各种源图像和参考图像对上的颜色转移结果。为了可视化,参考图像被裁剪为与其他图像相同的尺寸。 该存储库包含以下论文的官方PyTorch实现: 李俊勇,孙亨锡,李健熙,李钟hy,...
类比.LogViewer.PowerToys 日志的类比解析器
visual and inertial sensors.We term this estimation task visual-inertial odometry (VIO), in analogy to the well-known visual-odometry problem. We present a detailed study of EKF-based VIO algorithms, ...
然而在这些庞大而凌乱的资源库中发现有用的信息,对于人类或自动化技术来说仍是一个挑战。传统的解决方法有,具有高度关系结构(如谓词演算表征)但非常稀疏,且成本很高的人工创建的数据库。更为简单的机器学习/...
To keep with the car analogy, the prospective student is starting out trying to work on a Formula One engine without ever knowing how a two stroke motor operates. During their shop class the student ...
The source code of 'Visual Attribute Transfer through Deep Image Analogy'
Distributed word representations capture relational similarities ...based embeddings, but dependency structures can be used to improve analogy detection by filtering candidates. In addition, we show tha