欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    bxml详解教程.docx

    • 资源ID:13563933       资源大小:23.35KB        全文页数:22页
    • 资源格式: DOCX        下载积分:1金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要1金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    bxml详解教程.docx

    1、bxml详解教程BXML is an XML-based markup language for simplifying the construction of Java object hierarchies. While it is most often used to define the user interface of an Apache Pivot application, it is not limited to user interface construction, and can actually be used to create hierarchies of any o

    2、bject type. This document introduces the BXML language and explains how it can be used to create and configure a collection of Java objects. BXMLSerializerThe org.apache.pivot.beans.BXMLSerializer class is used to load a structure defined in a BXML file. This class implements the org.apache.pivot.se

    3、rialization.Serializer interface, which defines the readObject() method for reading an object value from an input stream: ?123456789public interface Serializer public T readObject(InputStream inputStream) throws IOException, SerializationException; public void writeObject(T object, OutputStream outp

    4、utStream) throws IOException, SerializationException; public String getMIMEType(T object); For example, the following code snippet loads a Window object declared in a file named my_window.bxml: ?1234BXMLSerializer bxmlSerializer = new BXMLSerializer(); Window window = (Window)bxmlSerializer.readObje

    5、ct(getClass().getResource(my_window.bxml); BXMLSerializer does not implement writeObject(), but does provide some additional conveniece methods for reading BXML as well as for localizing the deserialized structure using resource bundles. NamespacesIn BXML, an XML namespace represents a Java package.

    6、 Declaring a namespace associates the namespace prefix with the package, similar to how the import keyword is used in Java. For example, the following simple BXML associates the package com.foo with the foo namespace prefix: ?123 If this file were deserialized using BXMLSerializer, an instance of co

    7、m.foo.Bar would be returned by the call to readObject(). The following BXML, which maps the com.foo package to the default namespace, would produce the same results with slightly less verbose markup: ?123; More complex examples may use classes defined in multiple packages; multiple namespace prefixe

    8、s can be used for this purpose. The bxml NamespaceThe bxml namespace prefix is reserved and defines a number of elements and attributes that are used for internal processing. It is generally declared on the root element of a BXML document: ?123456 . The bxml namespace includes the following: The bxm

    9、l:id attribute, which is used to assign a variable name to an element declared in a BXML file. For example, the following markup would associate an instance of the Foo class with the ID myFoo. This variable is added to the documents variable namespace (which is different from the XML namespace used

    10、to import Java packages), and can then be referenced elsewhere in the file or by code that deserializes the file, via the BXMLSerializer#getNamespace() method: ?123 The tag, which is used to include external resources, including nested BXML documents. For example, the following markup would embed th

    11、e contents of the my_include.bxml file in the current document:?123; BXML includes are often used for partitioning content into manageable pieces (for example, when working on large applications or with multiple developers, or when defining reusable content templates). By default, each include is as

    12、signed its own variable namespace to avoid naming collisions with ancestor documents; however, this behavior can be overridden by adding an inline attribute with a value of true to the tag. The tag, which defines a block of script code within a BXML file. For example, the following script block defi

    13、nes a function named foo(), which can then be called from other script blocks in the document: ?1234567 function foo() . The default scripting language is JavaScript, but any JVM-compatible scripting language can be used. The language processing instruction is used to specify a different language; f

    14、or example, Groovy: ?123 Script blocks can also be defined in event handler attributes and elements. Scripting and event handling are discussed in more detail below. The tag, which is used to declare objects that will exist outside of the hierarchy but may be referred to elsewhere. For example, the

    15、following define block declares an instance of Foo named myFoo that is not processed as part of the document flow (in other words, would not be added to its parent element, if it had one) but can be referred to by variable name later in the document: ?12345 The tag, used to dereference a page variab

    16、le. For example, the Foo instance in the previous example could be dereferenced as follows elsewhere in the document: ?123 Wherever this tag appears, it will effectively be replaced by the value of the myFoo variable. The variable deference operator ($) can also be used to dereference page variables

    17、. This is discussed in more detail below. ElementsIn BXML, an XML element that does not begin with the reserved bxml namespace prefix represents one of the following: A class instance A property of a class instance A static propertyEach of these is discussed in more detail below.Class InstancesIf an

    18、 elements tag name begins with an uppercase letter (and it is not a static property setter; see below), it is considered a class instance. When BXMLSerializer encounters such an element, it creates an instance of that class. As discussed above, the XML namespace prefix is used to determine the Java

    19、package to which the class belongs. For example, the following BXML would produce an instance of the org.apache.pivot.wtk.Label class populated with the text Hello, World!: ?123 Class instance elements in a BXML file will often represent instances of Java bean types. Internally, BXMLSerializer uses

    20、an instance of org.apache.pivot.beans.BeanAdapter to wrap the instantiated class and invoke its setter methods. This class implements the org.apache.pivot.collections.Dictionary interface and allows a caller to get and set bean property values as key/value pairs. However, if the element represents a

    21、 type that already implements the Dictionary interface (such as org.apache.pivot.collections.HashMap), it is not wrapped and its dictionary methods are used directly. For example, the following BXML creates an instance of org.apache.pivot.collections.HashMap and sets its foo and bar values to 123 an

    22、d 456, respectively: ?123 How the foo and bar attributes are handled is discussed in more detail below. Instance PropertiesElements whose tag names begin with a lowercase letter represent instance properties. An instance property element may represent one of the following: A property setter A read-o

    23、nly sequence A read-only dictionary An event listener listProperty SettersIf the element represents a property setter, the contents of the element (which must be either a text node or a nested class instance element) are passed as the value to the setter for the property. For example, the following

    24、BXML creates an instance of the Label class and sets the value of the labels text property to Hello, World!: ?12345 Hello, World! This produces the same result as the earlier example which used an attribute to set the text property: ?123 The following example creates an instance of ListView and sets

    25、 the value of its listData property to an instance of org.apache.pivot.collections.ArrayList that has been populated with several instances of org.apache.pivot.wtk.content.ListItem: ?12345678910111213 Read-Only SequencesIf the property represents a read-only sequence (a bean property whose getter re

    26、turns an instance of org.apache.pivot.collections.Sequence and has no corresponding setter method), the contents of the element are added to the sequence. For example, the tabs property of the org.apache.pivot.wtk.TabPane class is a read-only sequence representing the tab panes tab components. Tabs

    27、can be added to a TabPane in BXML as follows: ?12345678 Read-Only DictionariesA property element may also represent a read-only dictionary (a bean property whose getter returns an instance of org.apache.pivot.collections.Dictionary but has no corresponding setter method). For example, the userData property of the org.apache.pivot.wtk.Component class represents a read-only dictionary: ?123456 userData foo=12


    注意事项

    本文(bxml详解教程.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开