マップを value にマーシャリングします。 JAXB の
問題
マップは通常、次のような XML 構造にマーシャリングされます。
<map> <entry> <key>KEY</key> <value>VALUE</value> </entry> <entry> <key>KEY2</key> <value>VALUE2</value> </entry> ... </map>
ただし、場合によっては、キーが要素名になり、値がその内容になります:
<map> <key>VALUE</key> <key2>VALUE2</key2> ... </map>
解決策
オプション 1: 動的に名前が付けられた XML 要素
動的属性名の使用は推奨されません。これは、XML スキーマとインターフェイス コントラクトの原則に違反します。
オプション 2: 列挙型キー タイプ
厳密なインターフェイス コントラクトを維持するには、マップに列挙型キー タイプを使用します。
public enum KeyType { KEY, KEY2; } @XmlJavaTypeAdapter(MapAdapter.class) Map<keytype string> mapProperty;</keytype>
オプション 3: 簡素化されたマーシャリング
デフォルトのマーシャリング構造を
class MapElements { @XmlAttribute public String key; @XmlAttribute public String value; // Required by JAXB private MapElements() {} public MapElements(String key, String value) { this.key = key; this.value = value; } } class MapAdapter extends XmlAdapter<mapelements map string>> { @Override public MapElements[] marshal(Map<string string> arg0) { MapElements[] mapElements = new MapElements[arg0.size()]; int i = 0; for (Entry<string string> entry : arg0.entrySet()) { mapElements[i++] = new MapElements(entry.getKey(), entry.getValue()); } return mapElements; } @Override public Map<string string> unmarshal(MapElements[] arg0) { Map<string string> r = new TreeMap(); for (MapElements mapelement : arg0) { r.put(mapelement.key, mapelement.value); } return r; } }</string></string></string></string></mapelements>
以上がJAXB を使用してマップを「value」要素にマーシャリングする方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

jvm'sperformanceiscompetitivewitherruntimes、sped、safety、andproductivityの提供

javaachievesplatformedentenceTheThejavavirtualMachine(JVM)、avainwithcodetorunonanyplatformwithajvm.1)codescompiledintobytecode、notmachine-specificcode.2)

thejvmisanabstractcomputingMachineCrucialForrunningJavaProgramsDuetoitsPlatForm-IndopentInterChitecture.Itincludes:1)ClassLoaderForloadingClasses、2)Runtimedataareaforforforatastorage、3)executionEngineWithinterter、Jitcompiler、およびGarbagecolfecolfecolfececolfecolfer

jvmhasacloserelationshiptheosasittrantesjavabytecodecodecodecodecodecodecodecodecodecodecodecodecodetructions、manageSmemory、およびhandlesgarbagecollection.thisrelationshipallowsjavatorunonvariousosenvirnments、Butalsedentsはspeedifediferentjvmbeviorhiorsandosendisfredediferentjvmbehbehioorysando

Javaの実装「Write and、Run Everywherewhere」はBytecodeにコンパイルされ、Java仮想マシン(JVM)で実行されます。 1)Javaコードを書き、それをByteCodeにコンパイルします。 2)JVMがインストールされたプラットフォームでByteCodeが実行されます。 3)Javaネイティブインターフェイス(JNI)を使用して、プラットフォーム固有の機能を処理します。 JVMの一貫性やプラットフォーム固有のライブラリの使用などの課題にもかかわらず、Woraは開発効率と展開の柔軟性を大幅に向上させます。

javaachievesplatformentenceTheTheTheJavavirtualMachine(JVM)、CodetorunondifferentoperatingSystemswithOutModification.thejvmcompilesjavacodeplatform-IndopentedbyTecodeを承認することを許可します

javaispowerfulfulduetoitsplatformindepentence、object-orientednature、richstandardlibrary、performancecapability、andstrongsecurityfeatures.1)platformendependenceallowseplicationStorunonaydevicesupportingjava.2)オブジェクト指向のプログラマン型

上位のJava関数には、次のものが含まれます。1)オブジェクト指向プログラミング、サポートポリ型、コードの柔軟性と保守性の向上。 2)例外処理メカニズム、トライキャッチ式ブロックによるコードの堅牢性の向上。 3)ゴミ収集、メモリ管理の簡素化。 4)ジェネリック、タイプの安全性の向上。 5)コードをより簡潔で表現力豊かにするためのAMBDAの表現と機能的なプログラミング。 6)最適化されたデータ構造とアルゴリズムを提供するリッチ標準ライブラリ。


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

Dreamweaver Mac版
ビジュアル Web 開発ツール

ZendStudio 13.5.1 Mac
強力な PHP 統合開発環境

メモ帳++7.3.1
使いやすく無料のコードエディター

WebStorm Mac版
便利なJavaScript開発ツール

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。
