Cast to a user class
Hi.
Suposse that I have got a class "MyClass" and then i add an object of "MyClass" into a container. If i retrieve all the component of the container with the method container.getComponents() i cant cast the component that i am stored in the array into "MyClass". How can i do it?? Do you know a way to do it??
Thank you.
MyClass must extend Component to have any chance at working. Even if MyClass extends Component, I believe you can not cast an array of one type to an array of another, even if the elements of the array have a relationship that allows the cast. For example...
Component[] comps = new Component[2];
comps[0]=new TextField();
comps[1]=new TextField();
TextField[] obs = (TextField[]) comps;
Even though a TextField is a Component, and the elements of the array are TextFields, you get a class cast exception if you run the above code. The getComponents() method returns an array of Components so I believe you will have to cast each element.
Similar Messages
-
RE: (forte-users) Class compatibility
Pascal,
Basically the way to work with objects as parameters is to ensure that
sending and receiving parties have the same knowledge of the underlying
classes of these objects.
o Partitions in one application, generated at distribution time always are
"in sync" with one another as they use the same class definitions specified
through the supplier plan relationships of the main project
o Applications distributed independently that exchanging objects only
understand the common set of class definitions.
For example, a Forte Conductor engine object is built using the standard
Forte Framework classes. Its API specifies things like "DataValue" objects.
Sending it a TextData is fine, sending it MyOwnTextData is not - the other
application has no clue what that (sub)class is supposed to be as it did not
know at the time it was built.
This is also true in cases where applications use libraries and these are
given objects of (sub)classes it knows nothing about.
All of these generate serialisation errors of some sort since the flattened
object that is sent across the wire cannot be reconstructed at the receiving
end by lack of a blueprint (class definition) on how to create such an
object.
Theo de Klerk
Architecture & Application Integration
Professional Services
Compaq Computer Corp. - the Netherlands
PGP Fingerprint: 5A70 DD56 F3BA FE04 9DCA 1ACE 8581 0A2F F057 FA6ETheo,
I understand all of that. Of course we make sure that all components use the
same blueprints for all classes. However, in case we managed to get these
blueprints out of sync, we don't want the application to simply crash. We
want to trap this exception and print a message that says: "There seems to
be a compatability problem between components. Please make sure the latest
version of all application components have been installed."
Of course we can trap all exceptions (GenericException) and ignore all of
them after displaying them, but that seems like a blunt-axe-approach. I'm
looking for the scalpel.
Pascal Rottier
Origin Nederland (BAS/West End User Computing)
Tel. +31 (0)10-2661223
Fax. +31 (0)10-2661199
E-mail: Pascal.Rottiernl.origin-it.com
++++++++++++++++++++++++++++
Philip Morris (Afd. MIS)
Tel. +31 (0)164-295149
Fax. +31 (0)164-294444
E-mail: Rottier.Pascalpmintl.ch
-----Original Message-----
From: Klerk, Theo de [mailto:Theo.de.Klerkcompaq.com]
Sent: Wednesday, October 18, 2000 5:15 PM
To: Rottier, Pascal; 'Forte Users'
Subject: RE: (forte-users) Class compatibility
Pascal,
Basically the way to work with objects as parameters is to ensure that
sending and receiving parties have the same knowledge of the underlying
classes of these objects.
o Partitions in one application, generated at distribution time always are
"in sync" with one another as they use the same class definitions specified
through the supplier plan relationships of the main project
o Applications distributed independently that exchanging objects only
understand the common set of class definitions.
For example, a Forte Conductor engine object is built using the standard
Forte Framework classes. Its API specifies things like "DataValue" objects.
Sending it a TextData is fine, sending it MyOwnTextData is not - the other
application has no clue what that (sub)class is supposed to be as it did not
know at the time it was built.
This is also true in cases where applications use libraries and these are
given objects of (sub)classes it knows nothing about.
All of these generate serialisation errors of some sort since the flattened
object that is sent across the wire cannot be reconstructed at the receiving
end by lack of a blueprint (class definition) on how to create such an
object.
Theo de Klerk
Architecture & Application Integration
Professional Services
Compaq Computer Corp. - the Netherlands
PGP Fingerprint: 5A70 DD56 F3BA FE04 9DCA 1ACE 8581 0A2F F057 FA6E
For the archives, go to: http://lists.xpedior.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com -
I have a parent class with a sub-vi Override.vi, and a child which overrides this sub-vi. I create an instance of this child. I cast this child to it's parent class and store it in an array. Later, if I invoke the parent's 'Override.vi' on this child (casted to parent) then Labview 2013 seems to randomly choose whether to run the parent or the child override.vi. In Labview 2011 SP1 it would always call the childs version of override.vi (which while surprising to me was very useful). This has totally broken an application I have been developing, any insight as to how to control which override.vi is run would be helpful (re-casting to the child class isn't really an option, as there are in fact many child classes each with their own version of override.vi).
The actual data type of the wire is irrelevant in deciding which VI to run. The only thing that is relevant is the class of the object which is actually on the wire, so casting to the parent should not be relevant. *IF* the object really is a child, then LV should always call the child's VI, just like you say it works in 2011.
I suspect that what's happening in your case is that somewhere you're generating a parent and that's what's actually on the wire (e.g. maybe you have an error somewhere and a function outputs the default value, which is a parent). The fact that it didn't happen in 2011 doesn't mean it's a bug in 2013. It could be that something else has changed.
In any case, it's impossible to tell whether this is a misunderstanding, a bug in your code or a bug in LV without actual code. If you can post actual code which shows this, people can help. Otherwise (if it only happens in code you don't want to publish), you should try contacting NI directly so that you can at least show them the code.
Try to take over the world! -
Does solaris dhcp server support user class
Does solaris dhcp server support user class(option 77). In my environment, solaris dhcp server seems just ignore this option set in the client dhcp discover.
Does anybody can help me.The clients are all Windows 7 x64 (but I've replicated the problem on MacOS and Solaris clients). The server is Solaris 11 x86.
For the problem to be the ARP cache, wouldn't the client's MAC address have to change during the reboot (i.e. the change in the client's MAC address is what causes the ARP cache to get confused, and hence the client gets blocked because of the MAC mismatch)?
Edited by: user13534003 on May 9, 2012 1:43 AM
Edited by: user13534003 on May 9, 2012 1:46 AM -
How to create a user class for the customer realm
how can I create a User class for my custom security realm, please help me out. i am trying to access using the active directory server and iam unable to write a simple classs for this user, can anyone help me. iam a beginner, would appriciate if any one helps me.regardsbaba
Hi Rawat,
You Don't need to create User Exits,but you need to find user Exits.Below are list of user Exits for MB31.
Use proper exit as per your requirement.
Exit Name Description
MBCF0002 Customer function exit: Segment text in material doc. item
MBCF0005 Material document item for goods receipt/issue slip
MBCF0006 Customer function for WBS element
MBCF0007 Customer function exit: Updating a reservation
MBCF0009 Filling the storage location field
MBCF0010 Customer exit: Create reservation BAPI_RESERVATION_CREATE1
MBCF0011 Read from RESB and RKPF for print list in MB26
MB_CF001 Customer Function Exit in the Case of Updating a Mat. Doc.
award points if ans is useful.
Regards,
Albert -
How to cast to a user given class..
Hi all....
Can u help me to create a generic method which take a class name
as String and cast one object to this class type and return.
Note :class name is provided as String.Hi Suresh.... you can't do such a thing.
public class Foo {
public static Object castTo(Object obj, String className) throws Exception {
Class clazz = Class.forName(className);
return clazz.cast(obj);
public static void main(String[] args) throws Exception {
Test2 s = new Test2();
Object o = castTo(s, "Test1");
System.out.println(o);
class Test1 {
public String toString(){
return this.getClass().toString();
class Test2 extends Test1 { } -
Cannot use user classes in webservices interface of appmodule custom method
Hi,
I need to expose an application module's custom method that uses user defined classes as parameters and return types as a web service interface. I have not been able to do that. Below are more details.
In particular, I have an app module that has a client interface with a custom method that takes and returns a serializable Emp object (user defined classes/objects). I need to expose this app module as a web service through the use of a service interface.
When i run the "Create Service Interface" wizard, under service custom methods (Create Service Interface Step 2 of 4 wizard), i don't see my custom method under "Available."
In addition, the JDev message log says: Business Components: Method "yourCustomMethod(Emp):Emp" cannot be exposed via service interface because the return type "com.mypackage.Emp" is not supported.
From what i understand by reading the docs below, it seems that in an application module's service interface (Webservice) you only can use simple data type or java.util.list or AttributeList (which is a wrapper for any viewRow). In other words, i cannot use my user defined object in the custom method parameters and return types.
This seems to be an artificial limitation of webservice creation through the use of app module because one can use complex/user defined objects in methods of a java class and expose them through a webservice.
I would appreciate if of the tooling PMs can make a well thought out comment.
11.2.3 What You May Need to Know About Method Signatures on the Service Interface
http://docs.oracle.com/cd/E12839_01/web.1111/b31974/bcextservices.htm#CJAEHFJD
9.8.4 What You May Need to Know About Method Signatures on the Client Interface
http://docs.oracle.com/cd/E12839_01/web.1111/b31974/bcservices.htm#CHDFHGII
Thanks,
AJ
ps: I am using Build JDEVADF_11.1.1.5.0_GENERIC_110409.0025.6013.Hi,
question 2 doesn't apply as the client interface is for Java access to public methods. For the Service Interface, the document lists the supported data types you can use in arguments and return values. To expose a custom methods, what about using a POJO that accesses ADF BC (using create root application module) and then expose your POJO as a JAWS service. This will allow you to expose the data queried from ADF BC through your custom classes.
Frank -
Casting to an abstract class from a different classloader
I have a class Special that extends an abstract class Base. In my code I use a URLClassLoader to load the class Special and I then want to cast Special to Base. If I do this I get a ClassCastException because the classes are loaded from different classloaders. I can't have the URLClassLoader and the class that performs the cast extend a parent ClassLoader that knows about the Base class. What I want to be able to do is something like this:
URLClassLoader loader = new URLClassLoader(codebase, null);
Class baseClass = loader.loadClass(className);
Base baseObj = (Base)baseClass.newInstance();
I have seen some post that suggest I can achieve this using Reflection but I am not sure how to go about this. Any help would be appreciated.
Thanks
Jim.Thanks for your help so far but I still can't do the casting, consider this example:
//Base.java
package classTest;
public interface Base
public abstract void execute();
//ConcBase.java
package classTest;
public class ConcBase implements Base
public void execute()
System.out.println("execute in ConcBase called");
I compile these files and jar them into work.jar
I now have my application:
//Test.java
import java.net.*;
import java.io.*;
import classTest.*;
public class Test
public static void main(String[] args)
Test t = new Test();
t.test();
public void test()
try
File file = new File("D:/Projects/classloadTest/work.jar");
URL[] codebase = {file.toURL()};
ClassLoader ccl = getClass().getClassLoader();
ccl.loadClass("classTest.Base");
URLClassLoader ucl = new URLClassLoader(codebase,ccl);
Class conClass = ucl.loadClass("classTest.ConcBase");
classTest.Base b = (classTest.Base)conClass.newInstance();
b.execute();
catch(Exception t)
System.out.println("thowable caught");
t.printStackTrace(System.out);
I compile this and run it with this command:
java -classpath D:\Projects\classloadTest\work.jar;. Test
This runs as I would expect, however I have set the parent class loader of my custom URLClassLoader to the one that does the cast, this means that Base and ConcBase are both being picked up by the application class loader as my custom class loader delegates to its parent. This is the current behaviour I have in my proper application and it is causing problems, I don't want the class that implements Base to delegate to any class on the main applications classpath. If I change the line:
URLClassLoader ucl = new URLClassLoader(codebase,ccl);
In Test.java to:
URLClassLoader ucl = new URLClassLoader(codebase,null);
I get a ClassCastException, this is because the class that does the cast (Test) loads Base from it's classpath and ConcBase is loaded from the URLClassLoader. After spending more time looking at this problem I don't think there is anyway to resolve but if anyone thinks there is please tell me.
Many thanks
Jim. -
Nasty narrowing cast (bug) in ServletAuthentication class
I'm trying to integrate a 3rd party's authentication framework with Weblogic using identity assertion. Like:
3rd party <- weblogic identity assertion <- custom SSO
The 3rd party is wrapping the HttpSession, which should be transparent. However, I get a class cast exception in BEA's ServletAuthentication class. It seems they do this nasty little narrowing cast on the HttpSession object.
public static int assertIdentity(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, String s)
throws ServletException, IOException, LoginException
if(authenticatedsubject != null && !SubjectUtils.isUserAnonymous(authenticatedsubject))
SessionInternal sessioninternal = (SessionInternal)httpservletrequest.getSession(true);
sessioninternal.setInternalAttribute("weblogic.authuser", authenticatedsubject);
SecurityServiceManager.pushSubject(getKernelID(), authenticatedsubject);
return 0;
} else
return 1;
Has anyone else run into this problem before? Anyone have a suggestion that doesn't involve me rewriting the 3rd party code or BEAs?Hi,
This may be a classloader problem. SessionInternal class instances are loaded by two different class loaders. Could you check with the thread link given below? It may be helpful you to nail down the issue.
http://forums.bea.com/bea/message.jspa?messageID=400002870&tstart=0
Keep posted your issue once gets resloved.
Cheers,
-Raja -
One Projector with shared casts and Multiple Users
I created a training program that was originally meant for
one user at a time. Now the client wants to
install the app on a network and have multiple users run the
same projector. When this is tested, an error comes up saying
that
a shared cast is already open by another user and will not allow
anyone else to run the app at the same time.
I was told there was a work around for this but have not been
able to track it down in the forums yet. If you know the solution,
please hit me back as soon as possible as you can imagine I am in
the hot seat. ;)
either hit me back here, OR directly at my email address:
[email protected]
Thanks!Make sure that the projector file and all the external casts
are set to
read-only. Then multiple users should be able to share them
all. -
Casting Object using imported class
The problem im having is when trying to de-serialize an obejct. the class that defines the object is stored in a different package and this code works fine when i move the class into the same package.
Im getting a ClassNotFoundException on the line with the >>
Any thoughts on why i cant cast using a class from another package?
private void loadTest(){
try {
FileInputStream fi = new FileInputStream("./Tests/"+plantComboBox.getSelectedItem()+"/"+mode+"/"+testComboBox.getSelectedItem()+"/"+testComboBox.getSelectedItem()+".test");
ObjectInputStream oi = new ObjectInputStream(fi);
>>test = (Test)oi.readObject();
//test.printTest();
oi.close();
} catch (Exception er) {
er.printStackTrace();
}Yeah i figured it out. The object that was serialized was made in a different project and was contained in a package called "main".
In my other project When i was running that method with the "Test" class in the same package as the method, it was, coincidently in the "main" package and when i moved it to my "test" package and the object was de-serialized it was being re-initialized with its package as "main" and throwing the error. -
Casting string to a class type
is it possible to typecast a string to a classtype?
Example:
if a string is stored in a vector v and xyz is a class then is the following statement correct :
((xyz)v.elementAt[2]) ??
if not then what should i do to typecast it?Navy_Coder wrote:
jverd wrote:
Navy_Coder wrote:
streetfi8er wrote:
is it possible to typecast a string to a classtype?
Example:
if a string is stored in a vector v and xyz is a class then is the following statement correct :
((xyz)v.elementAt[2]) ??
if not then what should i do to typecast it?Do you understand what typecasting is? What you're asking could be compared to taking your truck to a mechanic and asking if they can just turn it into a banana. You can't cast one object to another completely unrelated object.In fact, you can't cast objects at all.On second thought ......
enum Destination {
ETERNAL_DAMNATION, PITS_OF_HELL, OCEAN, VAT_OF_ACID;
ObjectManager.cast(myInstance, Destination.PITS_OF_HELLO);
ObjectManager.cast(calebsBrain, Destination.VAT_OF_ACID);
IMHO, this is still casting a reference, not an object. -
Weblogic User class extends deprecated class?
weblogic.security.acl.User extends java.security.Identity which is a
deprecated class for Java 1.2
I checked the 5.1 API docs, this class still extends the
java.security.Identity. Are there any plans to update this class or if there
is another class we should use instead of weblogic.security.acl.User ?
Srikanth Meenakshis> weblogic.security.acl.User extends java.security.Identity which is
s> a deprecated class for Java 1.2
This is not a problem. It's okay to use it.
<b
Let us pray:
What a Great System.
Please Do Not Crash.
^G^IP@P6 -
Invalid cast from another user
I was searched before in asktom.oracle.com how to do a varibale in list,i found the code and i used it. The code is
1)create or replace type myTableType as table
of varchar2 (255);
2)create or replace
function in_list( p_string in varchar2 ) return myTableType
as
l_string long default p_string || ',';
l_data myTableType := myTableType();
n number;
begin
loop
exit when l_string is null;
n := instr( l_string, ',' );
l_data.extend;
l_data(l_data.count) :=
ltrim( rtrim( substr( l_string, 1, n-1 ) ) );
l_string := substr( l_string, n+1 );
end loop;
return l_data;
end;
i was created the type and function in user called oraprog
and i used this query (through user oraprog) :
select * from table_name where column_name in
( select *
from THE ( select cast( in_list(:varibale)
as mytableType ) from dual ) )
the query was worked,but when i used this query (from another user) this message appeard:
ORA-22907: invalid CAST to a type that is not a nested table or VARRAY
my question is : why this message appearde?
and what is the solution?
please help me.I am not sure about the error message, but you can change your select to:
select * from table_name
where column_name in
(select *
from table(cast(in_list(:variable) as mytableType))); -
Javac.exe 1.4 is not finding user classes!!
! HELP !
Okay, I've used -classpath, i've messed around a bit with my settings, but for some reason, I can't get java to compile my code on my machine!!! I know it works, because I made and compiled it on machines on my school's account.
THE problem:
javac.exe keeps telling me that all of my own class objects are unresolved symbols, yet they ALL exist! and they are in the same directory! This happens with any outside class object reference in any class except Sun's predefined SDKs.
What the heck do I do?well well... Am I under the stupidly mistaken impression that the Platform kit is not the same as the Software Development kit?
I think I am...I am going to download the 1.31a sdk, and if it works, then I'm going to slap myself. hard. REALLY hard. :) GRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRack!ACKACKACKACKACKACKACKACKACKACKACKACK!
Maybe you are looking for
-
Not able to open a .pcz file in Windows XP
i have a .pcz file which i want to open in my win xp system. hope somebody cud help me out in this issue.
-
I run Mac 10.5.8 & Photos '08 7.1.5. In the past, when I'd open iPhoto, I'd get a list of all my events. I could click on an arrow and the event would open with all thumbnails present. I could click to open or drag to the trash easily. It's not that
-
Signatures no longer works in mail app
I started modifying my signatures and after a few changes they quit showing up so I deleted them and now I can't do anything.
-
Adobe Flash won't run on google chrome after downloading OS X Yosemite.
Adobe Flash Player is either running really slow or not running at all on Chrome. I tried Safari and it runs slow on that too. Tried redownloading adobe flash player and that didn't work. Everything on my computer is also running slow that uses inter
-
Genius freezes when gathering info from library
Hey, I'm hoping someone can help me with this. I haven't been able to get Genius to work, during the first step (Gathering information from your library) the progress bar reaches about 3/4 full and then iTunes proceeds to freeze. I restarted my compu