marshalling

JAXB marshal to string works differently on different computers

↘锁芯ラ 提交于 2020-01-06 05:26:04
问题 I have this test java app: @XmlRootElement public class Car { @XmlElement(namespace="http://www.example.com/CAR_NAME") private String name; @XmlElement(namespace="http://www.example.com/CAR_PRICE") private int price; @XmlElement(namespace="http://www.example.com/CAR_BUS") private Bus bus; //constructors, getters and setters @XmlRootElement public class Bus { @XmlElement(namespace="http://www.example.com/BUS_NAME") private String name; @XmlElement(namespace="http://www.example.com/BUS_PRICE")

how to map same value to two different fields in jaxb while marshalling and unmarshalling

烂漫一生 提交于 2020-01-06 04:10:16
问题 I have a xml tag Hello for which there is a field like below in my java class HelloWorld{ @XmlElement private String name; } While unmarshalling this successfully assigns Hello value to name variable.Now I want to create a new xml from THIS java object(HelloWorld) for which I am doing the marshalling but in this case I want a xml tag as instead of in my xml. How can I acheive this in Jaxb? Both Xml are not in my control so I cannot change the tag name EDIT: Incoming XMl - helloworld.xml

Marshaling structure to single line of string

可紊 提交于 2020-01-05 12:34:54
问题 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public class Comarea { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)] public string status; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 5)] public string operationName; } public static void StringToObject(string buffer, out Comarea comarea) { IntPtr pBuf = Marshal.StringToBSTR(buffer); comarea = (Comarea)Marshal.PtrToStructure(pBuf, typeof(Comarea)); } I can create object from single line of string but I can not do

Marshal save menu item of jlist to XML and unmarshal load menu items

只谈情不闲聊 提交于 2020-01-05 08:23:12
问题 I have been doing research on here and have been searching for a solution to the problem. I am new to java so I don't know all of the syntax. I am trying to get my code to transfer items from create methods for the save and load menu items. The save event handler should call a method save() and save the list of parts in the right panel to an XML file. The load event handler should call a method load() and it should display the unmarshalled data in the right panel. I am not familiar with JAXB

Passing a Structure containing an array of String and an array of Integer into a C++ DLL

自作多情 提交于 2020-01-05 07:10:36
问题 I'm having problems with marshaling in VB.NET to C++, here's the code : In the C++ DLL : struct APP_PARAM { int numData; LPCSTR *text; int *values; }; int App::StartApp(APP_PARAM params) { for (int i = 0; i < numLines; i++) { OutputDebugString(params.text[i]); } } In VB.NET : <StructLayoutAttribute(LayoutKind.Sequential)> _ Public Structure APP_PARAM Public numData As Integer Public text As System.IntPtr Public values As System.IntPtr End Structure Declare Function StartApp Lib "AppSupport

getting an Int/short/byte structure byte representation with C#

戏子无情 提交于 2020-01-04 13:35:20
问题 Given a FieldInfo object and an object, I need to get the actual bytes representation of the field. I know that the field is either int,Int32,uint,short etc. How can I get the actual byte representation? BinaryFormatter.Serialize won't help, since it'll give me more information than I need (it also records type name etc.). The Marshal class does not seem to have facilities to use bytes array (but maybe I'm missing something). Thanks 回答1: You may also try code like the following if what you

C# Marshal.Sizeof() when using custom marshaler

孤街浪徒 提交于 2020-01-04 09:54:18
问题 Is it possible to use Marshal.SizeOf() on a structure which is using a custom marshaler? For example: struct Abcde { public int test1; [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(MyCustomMarshaler)] public string customString1; } If I call: var size = Marshal.SizeOf(typeof(Abcde)); an exception is thrown which says that no meaningful size or offset can be computed. I noticed that ICustomMarshaler has a method called GetNativeDataSize() but the exception is thrown

Stuck on calling convention calling Managed CLI method from unmanaged C++

让人想犯罪 __ 提交于 2020-01-04 09:38:10
问题 I am trying to call a managed method from unmanaged code. However, the managed code is requiring that I use the '(__clrcall) calling convention, and my unmanaged C++ code refuses to let me use the __clrcall calling convention without using the /clr option. I don't believe I want to do that as the unmanaged project is not mine to change to managed. I have gone through constructing all those delegates and function pointer marshaling in the managed side as I have seen on CodeGuru and MSDN but

common dto for two incoming REST json

左心房为你撑大大i 提交于 2020-01-04 05:28:50
问题 I want to create a common dto like as shown below for receiving the incoming Manager and Staff details from a REST service public class Employee { @JsonProperty("name") public String name; @JsonProperty("designation") public String designation; @JsonProperty("item") public String item; @JsonProperty("item") public List<Item> items; //setters and getters } The problem is that for for Manager the item field will be a List where as for Staff it will be a string, so I have created two field for

common dto for two incoming REST json

好久不见. 提交于 2020-01-04 05:27:09
问题 I want to create a common dto like as shown below for receiving the incoming Manager and Staff details from a REST service public class Employee { @JsonProperty("name") public String name; @JsonProperty("designation") public String designation; @JsonProperty("item") public String item; @JsonProperty("item") public List<Item> items; //setters and getters } The problem is that for for Manager the item field will be a List where as for Staff it will be a string, so I have created two field for