|
|
Subject: Re: Ogojogi string output - msg#00037
List: cms.opengroupware.xmlrpc.devel
Hi murphee,
I managed to create my own UtfWorkaroundApacheXmlRpcCaller class wich
extends ApacheXmlRpcCaller. But I don't have a clue where to start with
my Utf82U class. I'm more or less a Java rookie.
Is it possible to use the Utf82U before the XML answer is parsed to an
object, or do I have to go through the result object? How can I rush
through the result object an change every item maked as string?
Greets
Christoph
murphee (Werner Schuster) wrote:
Christoph Guse wrote:
is there any chance to configure ogojogi, so I don't need the
follwing class?
public class Utf82U {
private String Utf8String;
private String UnicodeString;
public Utf82U(String utf8){
this.Utf8String = utf8;
byte[] temp = utf8.getBytes();
try{
this.UnicodeString = new String(temp,"UTF-8");
}
catch(Exception e){
this.UnicodeString = e.toString();
}
}
public String getString(){
return UnicodeString;
}
}
If I don't use this class to all strings I want to use in my
client-app, Umlaute are not shown correctly.
Hmmm.... just off the top of my head, look at the
http://ogo-jogi.sourceforge.net/doc/userguide.html where
the XmlRpc Caller Interface is explained.
Basically, you could do your own XmlRpc adapter, either by writing it
yourself or by decorating the ApacheXmlRpcCaller class.
Reason: every XmlRpc call goes through the XmlRpc object, so you could
do the UTF8 handling in there, ie. process each
String in there with your code (from your class) and replace them (for
arguments you get and the results from the OG.o server).
While this could prove as a bottleneck, I suppose there isn't any
better way to do this, and since you need to do the transformation
any other way, the overhead shouldn't be too bad.
Your own XmlRpcCaller class: you could either just copy the source of
ApacheXmlRpcCaller and adapt it, or (maybe better),
you create your own
class UtfWorkaroundApacheXmlRpcCaller extends ApacheXmlRpcCaller
and simply override the methods the methods in there to do your
pre-processing and postprocessing.
I hope this helps...
murphee
--
****************************************
Christoph Guse
Zimmer 33510
Hubertusstraße 149
41239 Mönchengladbach
Tel. 0 21 66 / 14 52 59
Mobil 01 72 / 160 74 84
****************************************
--
OpenGroupware.org XML-RPC
xmlrpc@xxxxxxxxxxxxxxxxx
http://mail.opengroupware.org/mailman/listinfo/xmlrpc
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: Ogojogi string output
Christoph Guse wrote:
is there any chance to configure ogojogi, so I don't need the follwing
class?
public class Utf82U {
private String Utf8String;
private String UnicodeString;
public Utf82U(String utf8){
this.Utf8String = utf8;
byte[] temp = utf8.getBytes();
try{
this.UnicodeString = new String(temp,"UTF-8");
}
catch(Exception e){
this.UnicodeString = e.toString();
}
}
public String getString(){
return UnicodeString;
}
}
If I don't use this class to all strings I want to use in my
client-app, Umlaute are not shown correctly.
Hmmm.... just off the top of my head, look at the
http://ogo-jogi.sourceforge.net/doc/userguide.html where
the XmlRpc Caller Interface is explained.
Basically, you could do your own XmlRpc adapter, either by writing it
yourself or by decorating the ApacheXmlRpcCaller class.
Reason: every XmlRpc call goes through the XmlRpc object, so you could
do the UTF8 handling in there, ie. process each
String in there with your code (from your class) and replace them (for
arguments you get and the results from the OG.o server).
While this could prove as a bottleneck, I suppose there isn't any better
way to do this, and since you need to do the transformation
any other way, the overhead shouldn't be too bad.
Your own XmlRpcCaller class: you could either just copy the source of
ApacheXmlRpcCaller and adapt it, or (maybe better),
you create your own
class UtfWorkaroundApacheXmlRpcCaller extends ApacheXmlRpcCaller
and simply override the methods the methods in there to do your
pre-processing and postprocessing.
I hope this helps...
murphee
--
Werner Schuster (murphee)
Student of SoftwareEngineering and KnowledgeManagement
Maintainer of the OGO-JOGI Project @ http://ogo-jogi.sourceforge.net/
Blog @ http://jroller.com/page/murphee
--
OpenGroupware.org XML-RPC
xmlrpc@xxxxxxxxxxxxxxxxx
http://mail.opengroupware.org/mailman/listinfo/xmlrpc
Next Message by Date:
click to view message preview
Re: Ogojogi string output
Christoph Guse wrote:
I managed to create my own UtfWorkaroundApacheXmlRpcCaller class wich
extends ApacheXmlRpcCaller. But I don't have a clue where to start
with my Utf82U class. I'm more or less a Java rookie.
Is it possible to use the Utf82U before the XML answer is parsed to an
object, or do I have to go through the result object? How can I rush
through the result object an change every item maked as string?
You'll have to go through the result object (the Apache XmlRpc Client
library handles the socket).
Generally: there are only a few types of XmlRpc types: of interest are
- String: if that is returned, simply use your code to create a
correct String object and return that
- collections: ie. lists or structs; with them, you simply have to
look at all of the items; if you find a
String, then simply replace it with a processed String; if you find
another collection object just recurse
into it, ie. look at each of it's elements and process them;
for a list, you'll get a java.util.Vector object (just look at each
element);
for a struct, you'll get a Hashtable object (there's a method called
keys(), which returns each key; with
this you get it's assignet value);
The methods in ApacheXmlRpcCaller return the object from the XmlRpc
call, so your methods could look something like this:
*public* Object invoke(String method_name, String string)
*throws* ConnectionException, OgoException
return processResult(super.invoke(method_name, string));
}
The "processResult" method would be your method that would take an
argument (an Object) and do what I
described above (the invoke method is overloaded, so you'll have to
override all of them).
murphee
--
Werner Schuster (murphee)
Student of SoftwareEngineering and KnowledgeManagement
Maintainer of the OGO-JOGI Project @ http://ogo-jogi.sourceforge.net/
Blog @ http://jroller.com/page/murphee
--
OpenGroupware.org XML-RPC
xmlrpc@xxxxxxxxxxxxxxxxx
http://mail.opengroupware.org/mailman/listinfo/xmlrpc
Previous Message by Thread:
click to view message preview
Re: Ogojogi string output
Christoph Guse wrote:
is there any chance to configure ogojogi, so I don't need the follwing
class?
public class Utf82U {
private String Utf8String;
private String UnicodeString;
public Utf82U(String utf8){
this.Utf8String = utf8;
byte[] temp = utf8.getBytes();
try{
this.UnicodeString = new String(temp,"UTF-8");
}
catch(Exception e){
this.UnicodeString = e.toString();
}
}
public String getString(){
return UnicodeString;
}
}
If I don't use this class to all strings I want to use in my
client-app, Umlaute are not shown correctly.
Hmmm.... just off the top of my head, look at the
http://ogo-jogi.sourceforge.net/doc/userguide.html where
the XmlRpc Caller Interface is explained.
Basically, you could do your own XmlRpc adapter, either by writing it
yourself or by decorating the ApacheXmlRpcCaller class.
Reason: every XmlRpc call goes through the XmlRpc object, so you could
do the UTF8 handling in there, ie. process each
String in there with your code (from your class) and replace them (for
arguments you get and the results from the OG.o server).
While this could prove as a bottleneck, I suppose there isn't any better
way to do this, and since you need to do the transformation
any other way, the overhead shouldn't be too bad.
Your own XmlRpcCaller class: you could either just copy the source of
ApacheXmlRpcCaller and adapt it, or (maybe better),
you create your own
class UtfWorkaroundApacheXmlRpcCaller extends ApacheXmlRpcCaller
and simply override the methods the methods in there to do your
pre-processing and postprocessing.
I hope this helps...
murphee
--
Werner Schuster (murphee)
Student of SoftwareEngineering and KnowledgeManagement
Maintainer of the OGO-JOGI Project @ http://ogo-jogi.sourceforge.net/
Blog @ http://jroller.com/page/murphee
--
OpenGroupware.org XML-RPC
xmlrpc@xxxxxxxxxxxxxxxxx
http://mail.opengroupware.org/mailman/listinfo/xmlrpc
Next Message by Thread:
click to view message preview
Re: Ogojogi string output
Christoph Guse wrote:
I managed to create my own UtfWorkaroundApacheXmlRpcCaller class wich
extends ApacheXmlRpcCaller. But I don't have a clue where to start
with my Utf82U class. I'm more or less a Java rookie.
Is it possible to use the Utf82U before the XML answer is parsed to an
object, or do I have to go through the result object? How can I rush
through the result object an change every item maked as string?
You'll have to go through the result object (the Apache XmlRpc Client
library handles the socket).
Generally: there are only a few types of XmlRpc types: of interest are
- String: if that is returned, simply use your code to create a
correct String object and return that
- collections: ie. lists or structs; with them, you simply have to
look at all of the items; if you find a
String, then simply replace it with a processed String; if you find
another collection object just recurse
into it, ie. look at each of it's elements and process them;
for a list, you'll get a java.util.Vector object (just look at each
element);
for a struct, you'll get a Hashtable object (there's a method called
keys(), which returns each key; with
this you get it's assignet value);
The methods in ApacheXmlRpcCaller return the object from the XmlRpc
call, so your methods could look something like this:
*public* Object invoke(String method_name, String string)
*throws* ConnectionException, OgoException
return processResult(super.invoke(method_name, string));
}
The "processResult" method would be your method that would take an
argument (an Object) and do what I
described above (the invoke method is overloaded, so you'll have to
override all of them).
murphee
--
Werner Schuster (murphee)
Student of SoftwareEngineering and KnowledgeManagement
Maintainer of the OGO-JOGI Project @ http://ogo-jogi.sourceforge.net/
Blog @ http://jroller.com/page/murphee
--
OpenGroupware.org XML-RPC
xmlrpc@xxxxxxxxxxxxxxxxx
http://mail.opengroupware.org/mailman/listinfo/xmlrpc
|
|