小编Mat*_*own的帖子

使用抽象基类类型遍历整个 JAXB 对象树

我为其编写软件的系统硬件通过树结构中的硬件进行物理连接。我们应用程序中的数据模型是一棵树。对于我们的新重写,我们使用 JAXB 创建数据模型。

我们有三种类型的设备,它们都共享一些属性,所以我在 XSD 模式中创建了一个抽象设备类型。我的三个设备(推送器、切换器、接收器)都是从 XSD 中的 DeviceType 扩展而来的,如下所示:

<xs:complexType name="DeviceType" abstract="true">
  <xs:sequence>
    <xs:element name="atrr1" type="xs:int"></xs:element>
    <xs:element name="attr2" type="xs:int"></xs:element>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="PusherType">
  <xs:complexContent>
    <xs:extension base="pts:DeviceType">
      <xs:sequence>
        <xs:element name="Switcher" type="pts:SwitcherType" minOccurs="1"></xs:element>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

<xs:complexType name="SwitcherType">
  <xs:complexContent>
    <xs:extension base="pts:DeviceType">
      <xs:sequence>
        <xs:element name="switcher" type="pts:SwitcherType" minOccurs="1"></xs:element>
        <xs:element name="receiver" type="pts:ReceiverType" minOccurs="1"></xs:element>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>
Run Code Online (Sandbox Code Playgroud)

Pusher 只有 switcher 子元素,而 switcher 可以同时有 switcher 或 receiver 子元素。接收者是线路的末端(叶节点)。xjc 构建类。我得到了 Unmarshaller 来构造对象树,但我不知道如何获得 getDevice() 的 getter 方法。对于树遍历,我希望 JAXB 会提供类似“getChildren”的东西,但我没有在 API 中看到。如果我得到一个切换器对象,我有 getSwitcher() 和 getReceiver() …

tree abstract-class jaxb tree-traversal

5
推荐指数
1
解决办法
1784
查看次数

无法从Eclipse Android SDK中的Properties中调出"Reference Chooser"窗口

使用本教程4.5:http: //www.vogella.de/articles/Android/article.html#first_uiproperties作为指南,我尝试"选择完整的小部件并使用Properties视图来设置属性"背景"到颜色属性"myColor"."

我可以选择小部件,突出显示"背景"属性,当我按下值列中的[...]按钮时,参考选择器窗口永远不会出现,并且值[...]按钮会消失.

可重复:永远

重现步骤:
1.在布局视图中
突出显示小组件2.突出显示背景属性
3.在值下按[...]按钮

android

1
推荐指数
1
解决办法
2300
查看次数

从遍历中获取顶点或路径时,Tinkerpop 非常慢

我的 Java 应用程序中有一个图形遍历,在遍历完成后需要 300 毫秒以上才能填充路径对象。这很奇怪,因为它只发生在某些特定的遍历上,而其他遍历会立即填充它们的路径。这是 Java 代码示例,使用 Tinkerpop 3.3.1

我有一种情况,两个顶点由一条边直接连接。每次执行这个短遍历时,我都会得到很高的处理时间。如果我不执行 fill() 操作,遍历会立即完成。我还有其他需要遍历 10 多个边的遍历,并且它们在 < 1 毫秒内处理和填充路径。

在下面的代码中,我试图找到从“origs”中的顶点到“dests”中的顶点的最短路径,而不经过集合“avoids”中的任何顶点。遍历本身在 1 毫秒内完成,它的 fill() 方法消耗了时钟。

    Date startTime = new Date ();
    if (! dests.isEmpty ()){
        g.V (origs).where (is (P.without (avoids))).    
        repeat (
                out ().
                simplePath ().
                where (is (P.without (avoids)))
                ).
                until (is (P.within (dests))).
                limit (1).
                path ().
                fill (paths);  // This 'fill' is the line that can take > 300ms.
                               // When fill is removed from the code,
                               // this all …
Run Code Online (Sandbox Code Playgroud)

java graph-theory gremlin tinkerpop tinkerpop3

1
推荐指数
1
解决办法
366
查看次数

SQL从DISTINCT行的结果中选择平均值

我正在尝试计算与SQL Server数据库中每个DISTINCT行关联的一组平均值,而我无法弄清楚如何将它们拼接在一起.我将用一个简单的例子来说明.下面的表格描述了获得3点A,B和C之间的时间.我试图计算出每次DISTINCT旅行之间的平均时间.

|Start|End|Time|
|  A  | B | 5  |
|  A  | B | 10 |
|  A  | B | 3  |
|  A  | C | 20 |
|  A  | C | 22 |
|  B  | C | 10 |
|  B  | C | 8  |

我想生成查询的结果

|Start|End|Avg|
|  A  | B | 6 |
|  A  | C | 21|
|  B  | C | 9 |

我已经尝试了一些关于连接和嵌套选择的东西,SELECT DISTINCT Start,End但是我有一些严重的语法问题来解决这个问题.没有太多的SQL经验.

马特

sql sql-server select distinct

0
推荐指数
1
解决办法
352
查看次数