Cache returns an Object of type ImmutableArrayList .
Hi.
I've a class that extends HashSet and I put it in the cache. When I retrieve it, I get an object of type ImmutableArrayList.
Any idea why or what's going on?
cheers
I'm pretty sure we are not using pof. Here is my cache-config.
<cache-config>
<caching-scheme-mapping>
<cache-mapping>
<cache-name>*</cache-name>
<scheme-name>dist-default</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<distributed-scheme>
<scheme-name>dist-default</scheme-name>
<backing-map-scheme>
<local-scheme>
<expiry-delay>86400</expiry-delay>
<flush-delay>3600</flush-delay>
</local-scheme>
</backing-map-scheme>
<autostart>true</autostart>
<request-timeout>120s</request-timeout>
</distributed-scheme>
</caching-schemes>
</cache-config>
I'll try and see whether it works by simply using Set instead of a HashSet?
Similar Messages
-
Returning an object that contains a collection WL 9.2
Hello,
I have a class like this:
public class data {
private Collection<MyObject> coll; //MyObject is another class
If I return this object from a web service call, i.e.
@WebService
public class HelloWorld {
@WebMethod
public data hello() {
I get an error saying java class MyObject is not known, which makes sense, because I only declared "HelloWorld" to jwsc task.
How can I make this class known, by annotation etc.?
Someone suggested to use "IncludeSchema" in the jwsc task, but apparently that has been deprecated.
Thanks!
Edited by ghosh007 at 02/21/2008 12:59 PM
Edited by ghosh007 at 02/21/2008 1:23 PMHi,
As you have this "Artiicle" class, extend it to be serializable and then define an Array of type Artiicle. So the return type would be an Array of a complex type i.e. Articles. In WSDL there will be type that defines an Array and this type can be used as a return message for your methode.
Try this, I think it will help you.
Regards, -
Using OFFLINE_INSTANTIATION with a spatial object - SDO_GEOMETRY type
Hello
I am looking for guidance on the usage of DBMS_REPCAT_RGT.INSTANTIATE_OFFLINE for a table object with an SDO_GEOMETRY
column defined.
The table is:
SQL> descr jtx.jtx_jobs_aoi
Name Null? Type
OBJECTID NOT NULL NUMBER(38)
JOB_ID NUMBER(10)
SHAPE MDSYS.SDO_GEOMETRY
SE_ANNO_CAD_DATA BLOB
The mview is defined as:
CREATE MATERIALIZED VIEW jtx.JTX_JOBS_AOI REFRESH FAST WITH PRIMARY KEY FOR UPDATE AS
SELECT * FROM JTX.JTX_JOBS_AOI@ncgsdb_master_s;
And the command we are using is:
SQL> SET SERVEROUTPUT ON
SQL>
SQL> DECLARE
2 dt_num NUMBER;
3 BEGIN
4 dt_num := DBMS_REPCAT_RGT.INSTANTIATE_OFFLINE(
5 refresh_template_name => 'jtx_refg_dt',
6 user_name => 'jtx',
7 site_name => 'NCGSDB_MVSITE1',
8 next_date => SYSDATE,
9 interval => 'SYSDATE + (1/96)');
10 DBMS_OUTPUT.PUT_LINE('Template ID = ' || dt_num);
11 END;
12 /
When we run this on an 11.1.0.6 database we get:
DECLARE
ERROR at line 1:
ORA-30373: object data types are not supported in this context
ORA-06512: at "SYS.DBMS_REPCAT_RGT_CUST", line 1991
ORA-06512: at "SYS.DBMS_REPCAT_RGT", line 1330
ORA-06512: at line 4
Now the strange thing is this appears to work for ONLINE_INSTANTIATION.
1. Is this supported?
2. If so what are we doing wrong?
Thanks
RichardHere a full example with CAST MULTISET as @PhilHerring wrote and with CAST COLLECT using the simplest possible function make_geometry:
CREATE OR REPLACE TYPE t_sdo_geometries AS TABLE OF MDSYS.sdo_geometry;
CREATE OR REPLACE FUNCTION make_geometry (p_points t_sdo_geometries)
RETURN t_sdo_geometries IS
BEGIN
RETURN p_points;
END;
SELECT make_geometry (
t_sdo_geometries (
sdo_geometry(2001, 32774, sdo_point_type(1, 1, null), null, null),
sdo_geometry(2001, 32774, sdo_point_type(2, 2, null), null, null),
sdo_geometry(2001, 32774, sdo_point_type(3, 3, null), null, null),
sdo_geometry(2001, 32774, sdo_point_type(4, 4, null), null, null)))
AS geom
FROM DUAL;
WITH geoms(pcol) AS
(SELECT sdo_geometry(2001, 32774, sdo_point_type(1, 1, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(2, 2, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(3, 3, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(4, 4, null), null, null) FROM dual)
SELECT make_geometry(cast(multiset(select pcol from geoms a) as t_sdo_geometries)) FROM dual;
WITH geoms(pcol) AS
(SELECT sdo_geometry(2001, 32774, sdo_point_type(1, 1, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(2, 2, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(3, 3, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(4, 4, null), null, null) FROM dual)
SELECT make_geometry(cast(collect(pcol) as t_sdo_geometries)) FROM geoms;
Hope that helps
_jum -
Converting object wrapper type array into equivalent primary type array
Hi All!
My question is how to convert object wrapper type array into equivalent prime type array, e.g. Integer[] -> int[] or Float[] -> float[] etc.
Is sound like a trivial task however the problem is that I do not know the type I work with. To understand what I mean, please read the following code -
//Method signature
Object createArray( Class clazz, String value ) throws Exception;
//and usage should be as follows:
Object arr = createArray( Integer.class, "2%%3%%4" );
//"arr" will be passed as a parameter of a method again via reflection
public void compute( Object... args ) {
a = (int[])args[0];
//or
Object arr = createArray( Double.class, "2%%3%%4" );
public void compute( Object... args ) {
b = (double[])args[0];
//and the method implementation -
Object createArray( Class clazz, String value ) throws Exception {
String[] split = value.split( "%%" );
//create array, e.g. Integer[] or Double[] etc.
Object[] o = (Object[])Array.newInstance( clazz, split.length );
//fill the array with parsed values, on parse error exception will be thrown
for (int i = 0; i < split.length; i++) {
Method meth = clazz.getMethod( "valueOf", new Class[]{ String.class });
o[i] = meth.invoke( null, new Object[]{ split[i] });
//here convert Object[] to Object of type int[] or double[] etc...
/* and return that object*/
//NB!!! I want to avoid the following code:
if( o instanceof Integer[] ) {
int[] ar = new int[o.length];
for (int i = 0; i < o.length; i++) {
ar[i] = (Integer)o;
return ar;
} else if( o instanceof Double[] ) {
//...repeat "else if" for all primary types... :(
return null;
Unfortunately I was unable to find any useful method in Java API (I work with 1.5).
Did I make myself clear? :)
Thanks in advance,
Pavel GrigorenkoI think I've found the answer myself ;-)
Never thought I could use something like int.class or double.class,
so the next statement holds int[] q = (int[])Array.newInstance( int.class, 2 );
and the easy solution is the following -
Object primeArray = Array.newInstance( token.getPrimeClass(), split.length );
for (int j = 0; j < split.length; j++) {
Method meth = clazz.getMethod( "valueOf", new Class[]{ String.class });
Object val = meth.invoke( null, new Object[]{ split[j] });
Array.set( primeArray, j, val );
}where "token.getPrimeClass()" return appropriate Class, i.e. int.class, float.class etc. -
Returning cloned objects from EJB Local Interfaces
We'd like to let our WAS 5/J2EE container manage our transactions/unit of work. However, we don't want to have our objects serialized, so we intend to use LocalInterfaces. Additionally, we want to return value objects that support Toplink indirection such that we are not returning the actual cache object but instead a clone.Our question is, how do we return a cloned object that supports indirection from Toplink that we can later do a deepMergeClone on in an explicit update method?
Additional Information on the first post:
The pattern we've been testing is as follows:
1. We set up LocalInterfaces on our EJB's
2. The EJB Getters are using acquireNonSynchronizedUnitOfWork() to get a NON-JTS transaction to perform a readQuery. This results in a Cloned Bis object being generated. We then release the UOW and return the object.
3. The Returned Biz object Getters are using Indirection (probably using the released non-synchronized UOW).
4. The pattern for UPDATE is that we allow the Web Container code (servlet) to change the Cloned Biz Object, they then submit the CLONED and changed object to an EJB update() method where we use getClientSession().getActiveUnitOfWork() to link to the JTS transaction and perform a uow.deepMergeClone(bizObjectClone);
We are trying to use the pattern for the following reasons:
1. Isolation of the Cache to upper layers
2. Transaction Boundry is the EJB Container
3. We understand that there is a performance overhead with CLoned Biz Objects but this more mirrors the ValueObject Pattern then anything else we've tried.
BIG Question:
1. Is this a supported TopLink Pattern?
2. If its not supported, can it be?
3. Do you have any other suggested patterns? -
Try to create a method to return an object as xml
I'm trying to create a method for an object to return the objects attributes in xml format.
here is what I have done so far:
-- create the object hierachy
create or replace type ras4.atomic_tp as object
(atomic_instance_id varchar2(8),
service_instance_id varchar2(8),
parent_atomic_instance_id varchar2(8),
MEMBER FUNCTION return_xml RETURN varchar2)
NOT INSTANTIABLE
NOT FINAL;
create or replace type ras4.parm_const_tp under ras4.atomic_tp
(parameter_name varchar2(75))
NOT INSTANTIABLE
NOT FINAL;
create or replace type ras4.contact_tp under ras4.atomic_tp
(address_line_1 varchar2(80),
address_line_2 varchar2(80),
address_line_3 varchar2(80),
city varchar2(20),
state varchar2(2),
country varchar2(20),
postal_code varchar2(20),
voice_telephone varchar2(20),
dns_telephone varchar2(20),
fax varchar2(20),
email varchar2(80),
url varchar2(20),
contact_inst varchar2(255))
NOT INSTANTIABLE
NOT FINAL;
create or replace type PERSON_tp under contact_tp
(prefix varchar2(7),
first_name varchar2(50),
middle_name varchar2(50),
last_name varchar2(50),
suffix varchar2(20),
nick_name varchar2(50),
OVERRIDING MEMBER FUNCTION return_xml return varchar2)
INSTANTIABLE
FINAL;
create table ras4.person_tb of ras4.person_tp;
insert into ras4.person_tb values
(ras4.person_tp('00001', '00001', '00001', '1111 Trail Lake Dr.', null, null, 'Fort Worth',
'TX', 'USA', '76233', '(817)346-0004', null, null, '[email protected]', 'www.tom.com', 'no calls after 10:00 please',
'Mr.', 'Tom', 'Scott', 'Tiegen', null, 'Tom'));
commit;
-- now different things I have tried to get the member function to work:
CREATE or replace TYPE BODY RAS4.PERSON_TP AS
overriding MEMBER FUNCTION RETURN_XML RETURN VARCHAR2 IS
qryCtx DBMS_XMLGEN.CTXHANDLE;
result CLOB;
BEGIN
qryCtx :=
DBMS_XMLGEN.NEWCONTEXT ('select self.first_name from dual;');
result := DBMS_XMLGEN.GETXML(qryCtx);
RETURN (RESULT);
END;
END;
I try to invoke the method as below:
DECLARE
v_person ras4.person_tp;
v_person_ref ref ras4.person_tp;
V_string varchar2(2000);
BEGIN
select value(a)
into v_person
from ras4.person_tb a
where a.atomic_instance_id = '00001';
v_string := v_person.return_xml;
DBMS_OUTPUT.PUT_LINE(v_string);
END;
I get the following error:
DECLARE
ERROR at line 1:
ORA-19206: Invalid value for query or REF CURSOR parameter
ORA-06512: at "SYS.DBMS_XMLGEN", line 83
ORA-06512: at "RAS4.PERSON_TP", line 7
ORA-06512: at line 12
-- I try to use
from the command line I type in this:
select sys_xmlgen(value(p))
from person_tb p
where p.atomic_Instance_id = '00001';
and it seems to work.
trying to put this into a member function - I try this:
CREATE or replace TYPE BODY RAS4.PERSON_TP AS
overriding MEMBER FUNCTION RETURN_XML RETURN VARCHAR2 IS
v_string varchar2(200);
v_person ras4.person_tp;
BEGIN
v_person := self;
select v_person.first_name into v_string from dual;
return (select sys_xmlgen(value(v_person)));
END;
END;
This fails to compile.
any help is greatly appreciated.
tomPN,
First, it's impossible to create static method with WD IDE designers for controllers.
Next, if you simply need to call method from wdDoModifyView, just create instance method createHTMLViewer in regular way then call it from wdDoModifyView via wdThis.createHTMLViewer().
Third, you may create this method manually directly in source code, just place it at the end of controller between comments //@begin other ... //@end.
Valery Silaev
EPAM Systems
http://www.NetWeaverTeam.com -
XI calling an Oracle Stored Procedure which returns an Object to XI
I am currently trying to call an Oracle Packaged/Procedure from XI which accepts a couple of parameters as I/O and returns an Object as one of the parameters.
I have created the Object within the Oracle Database CREATE OR REPLACE TYPE xy_jdbc AS OBJECT
column_name type ...etc
CREATE OR REPLACE TYPE xy_tab_jdbc AS TABLE OF xy_jdbc;
One of the parameters for the stored procedure is set up as this type xy_tab_jdbc this will be populated based upon one of the parameters passed into the Package/Procedure.
Is this possible? If it is, how do I map the returned object within XI?Dear Hilary,
the JDBC adapter does not support vendor-specific or non-scalar data types.
Workaround: Change the stored proc's signature not to use an object, but the object's fields instead.
Regards,
Thilo -
Cache distribution - Java object cache
Hi.
I'm trying to use Oracle Java Object Cache (cache.jar), the one included in the 9iAS 9.0.3.
Everything works fine but the cache distribution between different JVM:s.
Anyone got this to work?
Regards
Jesper
package test;
import oracle.ias.cache.*;
* Singleton Cache class.
public class Cache {
/** The singleton instance of the object. */
private static Cache instance = null;
/** The root region. */
private final static String APP_NAME = "Test";
* Protected constructor - Use <code>getInstance()</code>.
* @throws Exception if error
protected Cache() throws Exception {
CacheAccess.defineRegion(APP_NAME);
* Gets the singleton instance.
* @return The instance of the Cache object.
public static Cache getInstance() throws Exception {
if (instance==null) {
createInstance();
return instance;
* Creates the singleton instance in a thread-safe manner.
synchronized private static void createInstance() throws Exception {
if (instance==null) {
instance = new Cache();
* Put an object on the cache.
* @param name The object name
* @param subRegion The sub region
* @param object The object to cache
* @throws Exception if error
public static void put(String name, String subRegion, Object object) throws Exception {
CacheAccess appAcc = null;
CacheAccess subAcc = null;
try {
appAcc = CacheAccess.getAccess(APP_NAME);
// Create a group
Attributes a = new Attributes();
a.setFlags(Attributes.DISTRIBUTE);
appAcc.defineSubRegion(subRegion, a);
subAcc = appAcc.getSubRegion(subRegion);
if (!subAcc.isPresent(name)) {
subAcc.put(name, a, object);
} else {
subAcc.replace(name, object);
} catch (CacheException ex){
// handle exception
System.out.println(ex.toString());
} finally {
if (subAcc != null) {
subAcc.close();
if (appAcc != null) {
appAcc.close();
* Gets a cached object from the specified sub region
* @param name The object name
* @param subRegion The sub region
* @return The cached object
* @throws Exception if requested object not in cache
public static Object get(String name, String subRegion) throws Exception {
CacheAccess appAcc = null;
CacheAccess subAcc = null;
Object result = null;
try {
appAcc = CacheAccess.getAccess(APP_NAME);
subAcc = appAcc.getSubRegion(subRegion);
// define an object and set its attributes
result = (Object)subAcc.get(name);
} catch (CacheException ex){
// handle exception
throw new Exception("Object '" + name + "' not in cache region '" + subAcc.getRegionName() + "'.");
} finally {
if (subAcc != null) {
subAcc.close();
if (appAcc != null) {
appAcc.close();
return result;
* Invalidates all objects in all regions
public static void invalidateAll() throws Exception {
CacheAccess appAcc = CacheAccess.getAccess(APP_NAME);
appAcc.invalidate(); // invalidate all objects
appAcc.close(); // close the CacheAccess access
// Main method for testing purposes.
public static void main(String[] args) throws Exception {
try {
System.out.println(">> Caching object OBJ1 into region TEST1.");
Cache.getInstance().put("OBJ1", "TEST1", "Object cached in TEST1.");
System.out.println(">> Getting OBJ1 from cache region TEST1.");
System.out.println(Cache.getInstance().get("OBJ1", "TEST1"));
} catch (Exception ex) {
System.out.println(ex.getMessage());
Contents of JAVACACHE.PROPERTIES:
# discoveryAddress is a list of cache servers and ports
discoveryAddress = host1.myserver.com:12345,host2.myserver.com:12345
logFileName = c:\javacache.log
logSeverity = DEBUG
distribute = trueI have same problem
Exist some reason?
I'm testing Cache with isDistributed() method and I still got false!
Thanx -
I have some Oracle Tables with sequences for primary key and stored procs in packages to wrap up the insert commands. The sequences field are all declared as NUMBER.
I also have Datasets based on the tables and a DataAdapter for each package. The Datasets see the primary keys as System.Decimal. The DataAdapter sees the output primary key parameter to the stored procs as OracleDecimal.
tmp.Parameters.Add(new OracleParameter("P_ID", Oracle.DataAccess.Client.OracleDbType.Decimal, ParameterDirection.Output));
tmp.Parameters["P_ID"].SourceColumn = "ID";
When I call the Update on the DataAdapter the update happens on the DB and then I get the following error
System.ArgumentException : Unable to cast object of type 'Oracle.DataAccess.Types.OracleDecimal' to type 'System.IConvertible'.Couldn't store <231> in ID Column. Expected type is Decimal.
----> System.InvalidCastException : Unable to cast object of type 'Oracle.DataAccess.Types.OracleDecimal' to type 'System.IConvertible'.
If I change the Oracle parameter to Oracle.DataAccess.Client.OracleDbType.Int32 or Oracle.DataAccess.Client.OracleDbType.Int64 it works fine - any ideas why that would be ? I would expect System.Decimal to map to Oracle.DataAccess.Types.OracleDecimal.Hi,
If I change the Oracle parameter to Oracle.DataAccess.Client.OracleDbType.Int32 or Oracle.DataAccess.Client.OracleDbType.Int64 it works fine - any ideas why that would be ? I would expect System.Decimal to map to Oracle.DataAccess.Types.OracleDecimal.
I'm trying to do the same, but no matter what I do, I get the OracleDecimal error. Parameter is defined as:
bq. this._adapter.InsertCommand = new global::Oracle.DataAccess.Client.OracleCommand(); \\ this._adapter.InsertCommand.Connection = this.Connection; \\ this._adapter.InsertCommand.CommandText = "INSERT INTO PERSON\r\n (ID, SURNAME, NAME, BIRTHCITY, EMSO)\r\nV" + \\ +"ALUES (:ID, :SURNAME, :NAME, :BIRTHCITY, :EMSO) RETURNING ID INTO :ID";+ \\ this._adapter.InsertCommand.CommandType = global::System.Data.CommandType.Text; \\ param = new global::Oracle.DataAccess.Client.OracleParameter(); \\ param.ParameterName = "ID"; \\ param.DbType = global::System.Data.DbType.Int32; \\ param.OracleDbType = global::Oracle.DataAccess.Client.OracleDbType.Int32; \\ param.Direction = global::System.Data.ParameterDirection.Output; \\ param.IsNullable = true; \\ param.SourceColumn = "ID"; \\ this._adapter.InsertCommand.Parameters.Add(param);
But no luck... -
Unable to cast object of type OracleXmlType to type XmlDocument
Hello All:
I have an Oracle Procedure that is taking an XML Document as an output parameter.
oCommand.Parameters.Add("errorrecord", OracleDbType.XmlType).Value = System.DBNull.Value;
oCommand.Parameters["errorrecord"].Direction = System.Data.ParameterDirection.Output;
When I try to cast this as an XmlDocument so I can set it to my ErrorRecord variable (defined as XmlDocument) and pass it back out of the Web-Service
ErrorRecord = (XmlDocument)oCommand.Parameters["p_errorrecord"].Value;
I get the following error: "Unable to cast object of type 'Oracle.DataAccess.Types.OracleXmlType' to type 'System.Xml.XmlDocument'"
How do I cast / convert the Oracle XMLType back to a .Net XMLDocument to pass out of the function?
ThanksNo, I have not tried that yet, but I admit I don't fully understand the syntax in the document posted.
oCommand.Parameters.Add("p_errorrecord", OracleDbType.XmlType).Value = System.DBNull.Value;
ErrorRecord = GoCommand.Parameters["errorrecord"].Value; (this is returned as XmlType)
I don't quite understand the syntax in the posted URL:
Declaration
// C#
public XmlDocument GetXmlDocument();
How am I to use this to get the XMLDocument? -
Unable to cast object of type InfoObject to DestinationPlugin
I have created a web application to show the list of scheduled reports and with their destination Info using Business objects sdk. Locally on my computer i am able to show all the reports and the Ftp information. But when i move this application to QA server the application returns an error with a message.
"Unable to cast object of type 'CrystalDecisions.Enterprise.InfoObject' to type 'CrystalDecisions.Enterprise.DestinationPlugin"
I have noticed that the returned type of Object by the query on QA server is of type "InfoObject" and on localbox "CrystalDecisions.Enterprise.Dest.Ftp"
Query
Select * from ci_systemobjects where SI_NAME= ''", "CrystalEnterprise.Ftp"
Assemblies required by application are registered in the GAC with same version and same public token
Please let me know if anyone has a answer for this casting exception.Snippet:
Dim ftp As New Ftp(infoObject.PluginInterface)
Dim ftpOptions As New FtpOptions(ftp.ScheduleOptions)
You wouldn't be doing a direct runtime cast.
Sincerely,
Ted Ueda -
Warning: assignment from distinct Objective-C type
Hi,
I'm getting the waring in the title of my post, and I can't figure out why. If I change the name of one variable everywhere in my code, then the warning goes away. Here is the code that produces the warning (warning marked in code with comment):
#import "RandomController.h"
#import "RandomSeeder.h"
#import "MyRandomGenerator.h"
@implementation RandomController
- (IBAction)seed:(id)sender
seeder = [[RandomSeeder alloc] myInit];
[seeder seed];
NSLog(@"seeded random number generator");
[textField setStringValue:@"seeded"];
[seeder release];
- (IBAction)generate:(id)sender
generator = [[MyRandomGenerator alloc] myInit]; //<**WARNING**
int randNum = [generator generate];
NSLog(@"generated random number: %d", randNum);
[textField setIntValue:randNum];
[generator release];
So both the RandomSeed class and the MyRandomGenerator class have a method named myInit. If I change the line with the warning to:
generator = [[MyRandomGenerator alloc] aInit];
and also change the name of the method to aInit in the MyRandomGenerator.h/.m files, then the warning goes away. xcode seems to be telling me that two classes can't have a method with the same name--which can't be correct.
//RandomSeeder.h
#import <Cocoa/Cocoa.h>
@interface RandomSeeder: NSObject {
- (RandomSeeder*)myInit;
- (void)seed;
@end
//RandomSeeder.m
#import "RandomSeeder.h"
@implementation RandomSeeder
- (RandomSeeder*)myInit
self = [super init];
NSLog(@"constructed RandomSeeder");
return self;
- (void)seed
srandom(time(NULL));
@end
//MyRandomGenerator.h
#import <Cocoa/Cocoa.h>
@interface MyRandomGenerator: NSObject {
- (MyRandomGenerator*)myInit;
- (int)generate;
@end
//MyRandomGenerator.m
#import "MyRandomGenerator.h"
@implementation MyRandomGenerator
- (MyRandomGenerator*)myInit
self = [super init];
NSLog(@"constructed RandomGenerator");
return self;
- (int)generate
return (random() %100) + 1;
@end
//RandomController.h
#import <Cocoa/Cocoa.h>
#import "RandomSeeder.h"
#import "MyRandomGenerator.h"
@interface RandomController : NSObject {
IBOutlet NSTextField* textField;
RandomSeeder* seeder;
MyRandomGenerator* generator;
- (IBAction)seed:(id)sender;
- (IBAction)generate:(id)sender;
@end
//RandomController.m
#import "RandomController.h"
#import "RandomSeeder.h"
#import "MyRandomGenerator.h"
@implementation RandomController
- (IBAction)seed:(id)sender
seeder = [[RandomSeeder alloc] myInit];
[seeder seed];
NSLog(@"seeded random number generator");
[textField setStringValue:@"seeded"];
[seeder release];
- (IBAction)generate:(id)sender
generator = [[MyRandomGenerator alloc] myInit];
int randNum = [generator generate];
NSLog(@"generated random number: %d", randNum);
[textField setIntValue:randNum];
[generator release];
@end
Also, I couldn't figure out a way to create only one RandomSeed object and only one MyRandomGenerator object to be used for the life of the application--because I couldn't figure out how to code a destructor. How would you avoid creating a new RandomSeed object every time the seed action was called? Or, is that just the way things are done in obj-c?
Message was edited by: 7stud7stud wrote:
generator = [[MyRandomGenerator alloc] myInit]; //<**WARNING**
I can tell you why I might expect the subject warning, but doubt I'll be able to handle the likely follow-up questions, ok?
Firstly note that +(id)alloc, which is inherited from NSObject, always returns an id type, meaning an object of unspecified class. Thus the compiler can't determine the type returned by [MyRandomGenerator alloc], so doesn't know which of the myInit methods might run. This is the case whenever init is sent to the object returned by alloc, but your example is a little more complicated because the code has broken at least two rules for init methods: 1) By convention the identifier of an init method must begin with 'init'; 2) An init method must return an object of id type.
Each of the myInit methods returns a different "distinct" type, and neither of the methods is known to be an init, so the compiler isn't willing to guarantee that the object returned will match the type of the left hand variable. Do we think the compiler would be more trusting if the init methods followed the naming convention? Dunno, but that might be an interesting experiment. In any case, I wouldn't expect the compiler to complain if the myInit methods both returned an id type object.
For more details about why and how init methods are a special case you might want to look over Constraints and Conventions under "Implementing an Initializer" in +The Objective-C Programming Language+. The doc on init in the +NSObject Class Reference+ also includes a relevant discussion.
Hope some of the above is useful!
- Ray -
Multiple SDO_GEOMETRY Objects of type CIRCLE with the same LOCATION
Can i have a single MERCHANT LOCATION hold multiple SDO_GEOMETRY Objects of type CIRCLE ?
For example the use case , i need to have a SDO_GEOMETRY TYPE CIRCLE circle defined for a single MERCHANT LOCATION with a 2 Mile radius as well as a 5 Mile Radius.
is that even possible with Spatial? I know i can add a single geometry for a merchant at once, but i want to give the user the flexibility of choosing the type of geometry for the merchant based on set of rules. hence want to check if this can be done or not?
Thanks in AdvancePerson with no name,
Not clear exactly what you need to do here.
You can store two circles with the same centre in a single sdo_geometry but only if you use a polygon with the circle with the greatest radius being the outer ring and the smaller radius the inner ring.
I have a utility in my free COGO plsql package that allows me to create circles for PLANAR data pretty easily as follows:
-- Function...
Create
function CreateCircle(dCentreX in Number,
dCentreY in Number,
dRadius in Number)
return mDSYS.sdo_geometry
IS
dPnt1X NUMBER;
dPnt1Y NUMBER;
dPnt2X NUMBER;
dPnt2Y NUMBER;
dPnt3X NUMBER;
dPnt3Y NUMBER;
BEGIN
-- Compute three points on the circle's circumference
dPnt1X := dCentreX - dRadius;
dPnt1Y := dCentreY;
dPnt2X := dCentreX + dRadius;
dPnt2Y := dCentreY;
dPnt3X := dCentreX;
dPnt3Y := dCentreY + dRadius;
RETURN MDSYS.SDO_GEOMETRY(2003,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,4),MDSYS.SDO_ORDINATE_ARRAY(dPnt1X, dPnt1Y, dPnt2X, dPnt2Y, dPnt3X, dPnt3Y));
End;
select sdo_geometry(f.geom.sdo_gtype,
f.geom.sdo_srid,
sdo_point_type(f.centreX,f.centreY,null),
f.geom.sdo_elem_info,
f.geom.sdo_ordinates) as mcircle
from (select 10 as centreX,
10 as centreY,
sdo_geom.sdo_xor(cogo.CreateCircle(10,10,2),
cogo.CreateCircle(10,10,5),
0.005) as geom
from dual ) f;
-- Results
MCIRCLE
SDO_GEOMETRY(2003,NULL,SDO_POINT_TYPE(10.0,10.0,NULL),SDO_ELEM_INFO_ARRAY(1,1003,2, 11,2003,2),SDO_ORDINATE_ARRAY(10.0,15.0, 5.0,10.0, 10.0,5.0, 15.0,10.0, 10.0,15.0, 10.0,8.0, 8.0,10.0, 10.0,12.0, 12.0,10.0, 10.0,8.0))(This geometry looks like a donut.)
Note that I have included the centre coordinates in the sdo_point of the result sdo_geometry.
To extract each ring:
-- We need a function to return number of rings in a polygon as sdo_util.getNumElems() does not
Create
Function GetNumRings( p_geometry in mdsys.sdo_geometry,
p_ring_type in integer /* 0 = ALL; 1 = OUTER; 2 = INNER */ )
Return Number
Is
v_elements pls_integer := 0;
v_ring_count pls_integer := 0;
v_etype pls_integer;
v_ring_type pls_integer := case when ( p_ring_type is null OR
p_ring_type not in (0,1,2) )
Then 0
Else p_ring_type
End;
Begin
If ( p_geometry is not null ) Then
v_elements := ( ( p_geometry.sdo_elem_info.COUNT / 3 ) - 1 );
<<element_extraction>>
FOR v_i IN 0 .. v_elements LOOP
v_etype := p_geometry.sdo_elem_info(v_i * 3 + 2);
If ( ( v_etype in (1003,1005,2003,2005) and 0 = v_ring_type )
OR ( v_etype in (1003,1005) and 1 = v_ring_type )
OR ( v_etype in (2003,2005) and 2 = v_ring_type ) ) Then
v_ring_count := v_ring_count + 1;
End If;
END LOOP element_extraction;
End If;
Return v_ring_count;
End GetNumRings;
-- Query
with circles as (
SELECT SDO_GEOMETRY(2003,NULL,SDO_POINT_TYPE(10.0,10.0,NULL),SDO_ELEM_INFO_ARRAY(1,1003,2, 11,2003,2),SDO_ORDINATE_ARRAY(10.0,15.0, 5.0,10.0, 10.0,5.0, 15.0,10.0, 10.0,15.0, 10.0,8.0, 8.0,10.0, 10.0,12.0, 12.0,10.0, 10.0,8.0))
as geom
FROM dual
select sdo_util.extract(a.geom,1,e.ringNo) as circle
from circles a,
(select level as ringNo from circles a connect by level <= GETNUMRINGS(a.geom)) e;
-- Result
CIRCLE
SDO_GEOMETRY(2003,NULL,SDO_POINT_TYPE(10.0,10.0,NULL),SDO_ELEM_INFO_ARRAY(1,1003,2),SDO_ORDINATE_ARRAY(10.0,15.0, 5.0,10.0, 10.0,5.0, 15.0,10.0, 10.0,15.0))
SDO_GEOMETRY(2003,NULL,SDO_POINT_TYPE(10.0,10.0,NULL),SDO_ELEM_INFO_ARRAY(1,1003,2),SDO_ORDINATE_ARRAY(10.0,8.0, 12.0,10.0, 10.0,12.0, 8.0,10.0, 10.0,8.0))Not sure if this helps you at all....
regards
Simon -
In Safari, composing an E-mail message, when I click on "I" for italics, use italics for a word, then unclick "I" to return to the regular type face, it reverts to italics after I hit the "return" key to begin a new paragraph. How can I avoid that unwanted reverting to italics?
Hi ...
Open a Finder window. From the Finder menu bar click Go > Go to Folder
Type or copy paste the following:
~/Library/Caches/com.apple.Safari/Cache.db
Click Go then move the Cache.db file to the Trash.
Quit and relaunch Safari to test. -
How can i return an object isn't java object from webservice????
Hi !
I have a problem in my Project. When i call method return a java object from webservice , it 's too easy. But when i create my own object (ex:ClientRequest.class) , it doesn't work exactly T_T . When i return that object (on client, doesn't have ClientRequest.class) , i cann't access its static variables.
How can i do it ??
Please help me !
Thanks a lot !!!!!
class ClientRequest {
public static int i;
public static String s;
public ClientRequest() {
}You can use REFCURSOR type for this. In java SQL TYPES this is available too. In your PLSQL use REFCURSOR for that array and then take the same from java code. Look in the servelet programming book for this SQLTYPE and see PLSQL for handling refcursors. We have done this way and it works.
Maybe you are looking for
-
IOS 5.1 using cellular data with no apps open
Just upgraded iphone 4s to iOS 5.1. Now when I am not connected to wifi, my cellular data usage is constant and rapid. No apps are open, no data usage that I am aware of. But when I check the cellular data usage, it goes up by about 1MB every minu
-
Hi SAP Application team would like to get a list of any reports in PROD that have not been run in the last 12 months (or reports that have been run in PROD). Plan to use this to identify reports that we can archive. Is there any method or script to f
-
Preflight panel Info. shows my placed 300 ppi PDFs at much less effective resolution
Ï'm brand new to InDesign (graphic designer who primarily works in Illustrator, some Photoshop, until now). I understand resolution and PPI but not necessarily in-depth knowledge of the related necessary workflow needed within InDesign, if that makes
-
How do I view/print a pdf document in an email? I'm not getting the little hand icon.
-
Problem running OutboundDeliveryERPChangeRequestConfirmation_In
Hello Experts, I am trying to execute an ES (OutboundDeliveryERPChangeRequestConfirmation_In) present on the HU2 system through Web Service navigator, but I am getting the following error: CX_GDT_CONVERSION:Exception CX_SOAP_ROOT occurred (program: C