Returning a whole vector
I want to print out the objects in vector from a class called repeat in a class called output.
Should I have a get method in repeat.Then in my output class have a repeat variable called repeat then say repeat.getVector and then print the items in the vector
I want to print out the objects in vector from a
class called repeat in a class called output.
Should I have a get method in repeat.Yes.
Then in my output class have a repeat variable called repeat
then say repeat.getVector and then print the items in the vectorYes.
Similar Messages
-
Method to return ArrayList or Vector doesn't work, why?
Hi, I try to return a ArrayList or Vector from a method but it does not work.. wondering why and how to fix it? Thanks:)
class Class1{
public static main(...){
Class2 test = new Class2();
ArrayList<String> resp = test.class2method(...);
if(resp.get(4).equals(...)) {
class Class2{
public ArrayList class2method(int NumInt1, int NumInt2, ...) {
ArrayList<String> arrayTesting = new ArrayList<String>(13);
responses.set(2, Integer.toString(NumInt1));
responses.set(3, Integer.toString(NumInt2));
responses.set(4, Integer.toString(NumInt3));
responses.set(5, Integer.toString(NumInt4));
responses.set(6, Integer.toString(NumInt5));
return responses;
}what is responses? don't you want to return
arrayTesting?yes, responses is arrayTesting, sorry did notmention
that.what do you mean? is the code you posted a typo or
what you actually have in your code?It's more than 1000 lines codes so I decided not to posted them but here is part of them. My point is that i tried to return a ArrayList or Vector even with a simple code, it does not work. Thanks for your help.
public class DemoScript {
public DemoScript() throws IOException {
// register the shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
System.out.println("close prog");
endApp();
public void endApp() {
System.out.println("done!");
System.exit(0);
public static void main(String[] args) {
Parameters p = new Parameters();
VMF vm = null;
//Elements: [0]time, [1]MsgType, [2]NumInt1, [3]NumInt2, [4]NumInt3, [5]NumInt4, [6]NumInt5, [7]NumLong,
// [8]String1, [9]String2, [10]String3, [11]String4, [12]String5
// ArrayList<String> responses = new ArrayList<String>(13);
try {
MyScript my = new MyScript();
if(args.length == 5) {
p.vmHost = args[1]; p.vmPort = Integer.parseInt(args[2]);
p.guiHost = args[3]; p.guiPort = Integer.parseInt(args[4]);
} else if(args.length == 4) {
p.vmHost = args[1]; p.vmPort = Integer.parseInt(args[2]); p.guiHost = args[3];
} else if(args.length == 3){
p.vmHost = args[1]; p.vmPort = Integer.parseInt(args[2]);
} else if(args.length == 2){
p.vmHost = args[1];
} else {
System.out.println("Usage: java MyScript [port #] [voice mail hostname] <voice mail socket #> <GUI hostname> <GUI socket #>");
System.out.println("Default: <voice mail socket #> = "+p.vmPort+", <GUI hostname> = "+p.guiHost+", <GUI socket #> = "+p.guiPort);
System.exit(-1);
// String hostname;
//int port;
/* Check for input arguments */
//if(args[0] != null){
// port = Integer.parseInt(args[0]);
// hostname = args[1];
//} else {
// port = 2000;
// hostname = "10.0.0.228";
//System.out.println("tews");
vm = new VMF(p.vmHost, p.vmPort, p.guiHost, p.guiPort);
vm.logon();
//vm.portAbort(4);/*
vm.portCapture(3, 0);
//vm.portAbort(4);/*
//vm.portOnhook();
//vm.portOffhook();
////vm.portStop(3); //to stop a port current operation
//vm.portWaitring(); //vm will not resp until port detects ring
//vm.portOffhook();
//vm.portGetdigits(5, 7);
//vm.portDialdigits("201");
//for(int i=0;i<100000000;i++);
//vm.portCallprogress(3, 0, 10);
//System.out.println("d");
//for(int i=0;i<1000000;i++);
//vm.portGetdigits(5, 7);
//vm.portRecordfile(30, 1, "\\\\kanapak.ctlinc.local\\VMfiles\\test.wmv");
//vm.portClearDTMF();
//vm.portPlayfile("\\\\kanapak.ctlinc.local\\VMfiles\\test.wmv");
//vm.portPlayprompt(2);
//vm.portSpeaknumber(3845);
//vm.portSpeakdigits("1639123478866478909");//75655656566657867867*");
//vm.portExternalcall(4, "933");
ArrayList<String> response = vm.portInternalcall(2, "201");
System.out.println(response.get(4));
if(response.get(4).equals("DONE")) {
vm.portPlayprompt(1); vm.portPlayprompt(2);
} else if(response.get(4).equals("GONE")) {
vm.portSpeakttsstring("hello. This will create ");//a project with all of the proper SWT and JFace imports. Version 4.1.1 latest build released (SWT visual inheritance, enhanced SWT GridLayout support, non-visual beans, custom !!!SWT widgets, code generation enhancements, expose property, etc.)");
vm.portRelease();
vm.logoff();
vm = new VMF(p.vmHost, p.vmPort, p.guiHost, p.guiPort);
vm.logon();
vm.portCapture(Integer.parseInt(args[0]), 0);
vm.portOnhook();
vm.portOffhook();
// vm.portGetdigits(5, 7);
//vm.portRecordfile(30, 1, "\\\\kanapak.ctlinc.local\\VMfiles\\test.wmv");
//vm.portClearDTMF();
//vm.portPlayfile("\\\\kanapak.ctlinc.local\\VMfiles\\test.wmv");
vm.portPlayprompt(86);
// vm.portSpeaknumber(3845);
//vm.portSpeakdigits("1639123478866478909");//75655656566657867867*");
//vm.portExternalcall(4, "933");
//vm.portInternalcall(9, "82045");
//vm.portSpeakttsstring("hello. This will create");// a project with all of the proper SWT and JFace imports. Version 4.1.1 latest build released (SWT visual inheritance, enhanced SWT GridLayout support, non-visual beans, custom !!!SWT widgets, code generation enhancements, expose property, etc.)");
vm.portRelease();
vm.logoff();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
//catch "STOP PORT"
vm.logoff();
class VMF {
public ArrayList<String> portInternalcall(int rings, String dial_string) {
if (logon_status == 0) {
System.err.println("Error: logon required");
logoff();closeAndExit();
} else if (capture_status == 0) {
System.err.println("Warning: portCapture required");logoff();closeAndExit();
} else if (rings <1 || rings >999 || !checkDigits(dial_string)) {
System.err.println("Warning: portInternalcall( [1-999] , \"[0-9,A-D,F,P,a-d,f,p,*,#]\" )");
breakString(dial_string);
ostruct.write("", "IVR", "123", 188, captured_port, rings, 0, 0, 0, 0, str1, str2, str3, str4, str5);
sendToGUI("s", "", "IVR", "123", "188", Integer.toString(captured_port),
Integer.toString(rings), "0", "0", "0", "0", str1, str2, str3, str4, str5);
readStream();
recToGUI("r", Integer.toString(MsgType),Integer.toString(NumInt1),Integer.toString(NumInt2),
Integer.toString(NumInt3),Integer.toString(NumInt4),Integer.toString(NumInt5),
Integer.toString(NumLong),String1,String2,String3,String4,String5);
responses.set(2, Integer.toString(NumInt1)); responses.set(3, Integer.toString(NumInt2));
responses.set(4, Integer.toString(NumInt3)); responses.set(5, Integer.toString(NumInt4));
responses.set(6, Integer.toString(NumInt5));
return responses;
} -
RMI to servet to Access DB not returning any results in Vector
We have a servlet (on the TomCat 3.2.3 web server) that receives parameters from an RMI Server program. The connection is done through the use of the HttpUrlconnection. The doGet() of the HttpServlet reads the parameters and assigns them to a data object of type thisData (which consists essentially of private data members of type: Strings and integer and double variables). The objects are then assigned to a vector, which is then sent back from servlet via getOutputStream(). We get no compilation errors nor do we get any errors during runtime. The connection to the database (MS Access) seems ok as it works with just the client, excluding the RMI. There is no response at the client side when we do a query - no results are returned in the Vector (message says it is 'empty'). What could possibly be wrong? Is there any particular aspect that we should look at? Any immediate help would be greatly appreciated. Thank you. The code from the servlet is below. Please let us know if this is correct. Thank you.
Flag =request.getParameter("Flag");
int flag =Integer.parseInt(Flag);
if (Flag == 1) { // SELECT to get data to display in GUI
departdate=request.getParameter("depdate");
departcity=request.getParameter("depcity");
destincity=request.getParameter("destincity");
try{
sqlQuery.setString( 1, departdate );
sqlQuery.setString( 2, departcity );
sqlQuery.setString( 3, destincity );
}catch(SQLException except){ }
try {
ResultSet results = sqlQuery.executeQuery();
catch (SQLException myexcpt) {
JOptionPane message here }
try{
ResultSetMetaData queryMetaData = results.getMetaData();
if ( noOfRecords >0 ) {
ObjectOutputStream outtoRMI = new ObjectOutputStream
(response.getOutputStream() );
results.beforeFirst();
thisData anObject = new thisData();
Vector theRecords = new Vector();
while ( results.next() )
// get value from ResultSet, then 'set' to an attribute
anObject.setClientNo( results.getInt(1) );
anObject.setAirline( results.getString(2) );
anObject.setdepartCity( results.getString(3) );
anObject.setdepDate(results.getString(4) );
anObject.setdepTime( results.getInt(5) );
anObject.setdestnCity(results.getString(6) );
anObject.setPrice( results.getDouble(7) );
anObject.setFlightNum( results.getInt(8) );
theRecords.addElement( anObject );
outtoRMI.writeObject( theRecords ); // write vector
outtoRMI.close(); // close writer
} // end of if
results.close(); // close resultSet
sqlQuery.close(); // close query
catch(SQLException nextExcept){ }
} // end of if stmtSorry, variable noOfRecords is set by result of getRow(). (When editing to display this, I inadverdently missed/deleted :)
Specifically wondering if use of ObjectOutputStream (response.getOutputStream) is appropriate.
In other words if a vector of complex objects (attributes of int, String, and double) can be sent back to RMI server via this mechanism. I have heard that only an object at a time (not a whole vector of them) can be transmitted. Is this true???
Relevant (corrected) code follows:
ResultSetMetaData queryMetaData = results.getMetaData();
results.last();
int noOfRecords = results.getRow();
if ( noOfRecords >0 ) {
if ( noOfRecords >0 ) {
ObjectOutputStream outtoRMI = new ObjectOutputStream
(response.getOutputStream() );
results.beforeFirst();
thisData anObject = new thisData();
Vector theRecords = new Vector();
while ( results.next() )
// get value from ResultSet, then use 'set' methods to set an attribute
anObject.setClientNo( results.getInt(1) );
//etc.
theRecords.addElement( anObject );
outtoRMI.writeObject( theRecords ); // write vector
outtoRMI.close(); // close writer
} // end of if -
Why my vector() always always return the last record?
Whenever i uses Vector, my whole vector always return the last element.. why?? Anyway to solve this?
some examples of my codes..
(String)rowVector.elementAt(2)
My rowVector vector always return the last element..
while(rs1.next())
Vector rowVector = new Vector();
for (int currentCol = 0; currentCol < numCols; currentCol++)
rowVector.add(rs1.getString (currentCol + 1));
tableData.addElement(rowVector);That means that every element in the Vector refers to the same object. I am surprised that your JDBC driver does not return different string objects for each call, but to work around that, try this:
rowVector.add(new String(rs1.getString (currentCol + 1))); -
Returning vector and null pointer exception
Hi, I'm writing a mailing program which so far is working fine, but I have now run into a problem which is completely throwing me. My mailer needs to be able to load multiple attachments - and also to be able to deal with an HTML text which contains multiple images. In each case, what I'm trying to do is to put the attachments and the images into separate vectors and process them through an iterator. The logic, at least, I hope is correct.
I can get my code to compile but it keeps throwing a null pointer exception a runtime. Somehow, I just can't get it to pass the vector from one part of the code to another.
Can anyone help me? I've tried various things, none of which seem to work. My code, as it stands, is posted in a skeletal form below.
Thanks for any ideas:
public class MailSender
// declare various variables, including:
Vector embeddedImages;
String HTMLString;
public MailSender()
setup();
private void setup()
//this part of the program sets up the various parts of the mail (to, from, body etc)
HTMLString = "blah blah blah"; //sample HTMLString
Vector embeddedImages = null; //is this correct?
if (HTMLString.length() > 0)
processHTMLString(HTMLString);
private String procesHTMLString(String htmlText)
Vector embeddedImages = new Vector(); // I construct my vector here, is this correct?
//Here I process the HTML string to extract the images
//get the file path of the image and pass it to the vector
addToVector(imageFile);
return HTMLString;
public Vector addToVector(String imageFile)
embeddedImages.add(imageFile);
return embeddedImages;
private void send()
//this part does the sending of the mail
//at some part in this method I need to get at the contents of the vector:
//but this part isn't working, I keep getting a null pointer exception
Iterator singleImage = embeddedImages.iterator();
while (singleImage.hasNext())
public static void main(String[] args)
MailSender ms = new MailSender();
ms.send();
System.out.println("MailSender is done ");
}>>>>while they don't have a clue on how the language and/or programming in general works.
Thank you, salpeter, for your esteemed estimation of my programming competence.
>>>What I'm wondering is: how come people always start building applications... blah blah
The reason being, is that it happens to be my job.
OK, I'm perhaps slower than most and there are things I don't yet understand but I get paid probably about a tenth of what you do (and maybe even less). I regard it as a kind of apprenticeship which, after a past life having spent twenty years packing crates in a warehouse, is worth the sacrifice. Six months ago I'd never written a line of code in my life and everything I've learned since has been from books, the good people in these forums, and a lot of patient trial and error. It's hard work, but I'll get there.
I say this, only as encouragement to anyone else who is trying to learn java and hasn't had the benefit of IT training at school and a four year computing course at university paid for by the parents, and for whom the prohibitive cost (in both time and money) of most java courses would never allow them to get on this ladder.
Excuse my somewhat acerbic posting, but comments such as yours tend to provoke...
Thank you EverNewJoy for explaining this to me. I haven't had time yet to try it out, but at least the concept now is clear to me. -
Stub generated in Jdev9i for webservice with 'Vector' return type
Hi,
In the OAF page that I am developing, I am trying to consume a web service generated in SAP PI using Jdeveloper. My Jdeveloper version is 9.0.3.5(I need to use this version since I need to deploy the OAF page in EBS11i). The stub generated based on the WSDL is given below.
import oracle.soap.transport.http.OracleSOAPHTTPConnection;
import org.apache.soap.encoding.soapenc.BeanSerializer;
import org.apache.soap.encoding.SOAPMappingRegistry;
import org.apache.soap.util.xml.QName;
import java.util.Vector;
import org.w3c.dom.Element;
import java.net.URL;
import org.apache.soap.Body;
import org.apache.soap.Envelope;
import org.apache.soap.messaging.Message;
* Generated by the Oracle9i JDeveloper Web Services Stub/Skeleton Generator.
* Date Created: Tue Jan 25 16:12:55 IST 2011
* WSDL URL: file:/C://Working/XXXXXXX/RegConsComplaint_OB.wsdl
public class RegConsComplaint_OBServiceStub
public RegConsComplaint_OBServiceStub()
m_httpConnection = new OracleSOAPHTTPConnection();
public static void main(String[] args)
try
RegConsComplaint_OBServiceStub stub = new RegConsComplaint_OBServiceStub();
// Add your own code here.
catch(Exception ex)
ex.printStackTrace();
public String endpoint = "http://XXXXXX:8000/sap/xi/...../RegConsComplaint_OB";
private OracleSOAPHTTPConnection m_httpConnection = null;
private SOAPMappingRegistry m_smr = null;
public Vector RegConsComplaint_OB(Element requestElem) throws Exception
URL endpointURL = new URL(endpoint);
Envelope requestEnv = new Envelope();
Body requestBody = new Body();
Vector requestBodyEntries = new Vector();
requestBodyEntries.addElement(requestElem);
requestBody.setBodyEntries(requestBodyEntries);
requestEnv.setBody(requestBody);
Message msg = new Message();
msg.setSOAPTransport(m_httpConnection);
msg.send(endpointURL, "http://sap.com/xi/WebService/soap1.1", requestEnv);
Envelope responseEnv = msg.receiveEnvelope();
Body responseBody = responseEnv.getBody();
return responseBody.getBodyEntries();
}I am wondering whether I will be able to use this stub generated by Jdeveloper since the input type is 'Element' and return type is 'Vector'; while in the Jdeveloper documentation the supported "primitive XML Schema types and arrays of primitive XML Schema types as parameters and return values for web services" do not include either of the two.
Regards,
SujoyHi Sujoy
I have been having big problems consuming microsoft sharepoint webservices using jDeveloper 9i.
Problems with jdk version compatability with jDev and NTLM authentication (Sharepoint).
so switching to db connection using utl_http.
Can you pls send me the code set for reference at [email protected]
thanks.
Regards
Sachin -
Query to return list of all missing primary key ids from table T1
I found this query online that returns a start and stop for a range of all missing primary key id values from table T1. However i want to rewrite this query to return a whole list of all the missing primary key ids and not a start and stop range. any help plz?
select strt, stp
from (select m.id + 1 as strt,
(select min(id) - 1 from T1 x where x.id > m.id) as stp
from T1 m left outer join T1 r on m.id = r.id - 1 where r.id is null)x where stp is not nullwith t as
select 1 as id from dual union all
select 2 as id from dual union all
select 3 as id from dual union all
select 5 as id from dual union all
select 8 as id from dual union all
select 10 as id from dual union all
select 11 as id from dual union all
select 20 as id from dual
select id_start + level missing_id
from (
select id id_start,
nullif(lead(id) over(order by id) - 1, id) id_end
from t
start with id_end is not null
connect by prior id_start = id_start
and prior dbms_random.random is not null
and level <= id_end - id_start
MISSING_ID
4
6
7
9
12
13
14
15
16
17
18
MISSING_ID
19
12 rows selected.Or:
with t as
select 1 as id from dual union all
select 2 as id from dual union all
select 3 as id from dual union all
select 5 as id from dual union all
select 8 as id from dual union all
select 10 as id from dual union all
select 11 as id from dual union all
select 20 as id from dual
select id_start + level - 1 missing_id
from (
select min(id) id_start,
max(id) id_end
from t
connect by level <= id_end - id_start
minus
select id
from t
MISSING_ID
4
6
7
9
12
13
14
15
16
17
18
MISSING_ID
19
12 rows selected.SY. -
Can not find individual element in the Vector
Hi everyone,
I have employeeRecord class .
I have employee Vector.
I have created two employeeRecord and added them to my employee Vector.
I am trying to test my employee Vector by using lgName = "rez704" .
However I do not see any result.
I was expecting the for loop to go through my employee Vector and
find the login name which matches with my test variable lgName.
ANy clues?
many thanks
Vector employeeVector = new Vector();
Enumeration e = empVector.elements();
String nameLog = "rea700";
String fName = "ameri";
String passW = "765";
employeeRecord emp = new employeeRecord(nameLog, fName, passW);
empolyeeVector.addElement(emp);
String nameLog2 = "rez704";
String fName2 = "Xamre";
String passW2 = "kv281"
employeeRecord emp = new employeeRecord(nameLog2, fName2, passW2);
empolyeeVector.addElement(emp);
String lgName = "rez704";
int i = 0;
for(Enumeration e1 = employeeVector.elements() ; e1.hasMoreElements() ;)
if (lgName.equals(empVector.elementAt(i)))
System.out.println("Login Name Found");
e1.nextElement();
}Hi everyone,
I have employeeRecord class .
I have employee Vector.
I have created two employeeRecord and added them to
my employee Vector.
I am trying to test my employee Vector by using
lgName = "rez704" .
However I do not see any result.
I was expecting the for loop to go through my
employee Vector and
find the login name which matches with my test
variable lgName.
ANy clues?
many thanks
Vector employeeVector = new Vector();
Enumeration e = empVector.elements();
String nameLog = "rea700";
String fName = "ameri";
String passW = "765";
employeeRecord emp = new employeeRecord(nameLog,
g, fName, passW);
empolyeeVector.addElement(emp);
String nameLog2 = "rez704";
String fName2 = "Xamre";
String passW2 = "kv281"
employeeRecord emp = new employeeRecord(nameLog2,
2, fName2, passW2);
empolyeeVector.addElement(emp);
String lgName = "rez704";
int i = 0;
for(Enumeration e1 = employeeVector.elements() ;
; e1.hasMoreElements() ;)
if
if (lgName.equals(empVector.elementAt(i)))
System.out.println("Login Name
tln("Login Name Found");
e1.nextElement();
Hi Guys,
No, none of the solution works!!
I tired the following just for testing.
int l = 0;
if ( empVector.elementAt(l).equals(e1.nextElement()) )
<
<
<
it only prints the first employee record
Login Name Found
login Name = reza700
Last name = ameri
passWord = 765
in my original question which I had posted, I wanted to compare not the whole Vector object but
only to access loginName whithin the emplyoeeVector and comapare it
with the lgName which is used as testing.
But the example which I had uesed above and it the wrong type of example the wole emplyoee record is found in the emplyoee vector.
any help is appreciated.
thank you again -
NEED HELP on returning values from a method
Hello Java World,
Does anyone know how to return more then 1 value from a method..
ex.
//the following returns one value
//Person Class
private String getname()
return this.name;
how can i get two values (ex. name and occupation of person)
Thank you in advance.Create a Class which will hold the values you want and return that object. Or return a List, or return an array, or - taking your example with the person, why don't you return the whole person object?
Thomas -
Returning multiple values from a method
I have to return a string and int array from a method (both are only of size 5 for a total of 10) What would be considered the best manner in which to do this ?
Dr there's 10 points in it for you or whoever gives me the best idea ;-Phey here it is easy that you can return many things
what ever you want from a single method man....
you know the main thing what you have to do is.....
Just create a VECTOR or LIST object, then add all the
values what ever you want to return like string and
int array like etc...
Then make the method return type is VECTOR and after
getting the Vector you can Iterate that and you can
get all the values from that method what ever you
want....
jus try this,,,,,,,,,,
Its really work......
reply me..but it relies purely on trust that the returned collection would contain exactly the right number and type of arguments -
Want to print the whole month with or without overtime for each employee
Hi,
I have Oracle forms/reports10g R2, Below query returns employee overtime correctly but I want to add the whole month with it in simple words if one employee have overtime for five days in a month I want the query to return the whole month including five overtime days for each employee and let say if we have ten employees query return whole month for each employee either he have or overtime or not how can I implement this in report it becomes agony for me, anyone please suggest a solution.
Thanks and regards, Khawar.
---Query---
select o.ot_date , o.start_dt_time as start_time, o.end_dt_time as end_time, o.ot_details, et.holiday, et.staff_id, e.staff_name, e.desig
from overtime o, emp_ot et, employee e
where o.complain_no = et.complain_no
and o.inc_type_code = et.inc_type_code
and et.staff_id = e.staff_id
order by 1, 2, 3, e.staff_idHi Michael,
Thanks for reply, I think I didn't explain as I should, I want to print Overtime report for each employee let say employee A123 did overtime for five days in DEC than what I want is to print report for employee A123 for the whole month means when I print report blank cell should come where A123 don't have data (I mean other 25/26 days).
The structure of tables are as
SQL> desc overtime
Name Null? Type
COMPLAIN_NO NOT NULL NUMBER(5)
OT_DATE NOT NULL DATE
START_DT_TIME NOT NULL DATE
INC_REF_NO NUMBER(5)
END_DT_TIME NOT NULL DATE
INC_TYPE_CODE NOT NULL VARCHAR2(10)
DISTRICT_CODE VARCHAR2(6)
BUSBAR_VOL VARCHAR2(5)
OT_DETAILS VARCHAR2(2000)
SQL> desc EMP_OT
Name Null? Type
STAFF_ID NOT NULL VARCHAR2(8)
COMPLAIN_NO NOT NULL NUMBER(5)
INC_TYPE_CODE NOT NULL VARCHAR2(10)
HOLIDAY NUMBER
Each employee associated with primary key i.e COMPLAIN_NO and INC_TYPE_CODE
in each OVERTIME table record we may have more than one employee in EMP_OT table.
above detail may clear my query.
Thanks and Regards,
Khawar. -
How do I get 2 decimal places when using a formula for a quotient? It only gives me whole integers. Most of the results will be less than 1 so I need 2 decimal places
the quotient function returns only whole number portion of the dividing two numbers. If you want the actual decimal value use the divide operator. you enter this as:
A/B
if the numerator is in A1 and the denominator is in B1 you can enter the formula like this:
=A1/B1 -
Hi All How to TypeCast in vector<>... typedef struct ... to class...
//how to cast the vector to vector cast with out using loop
// is there any way?
//================ This is Type Definition for the class of ClsMytype=====================
typedef struct tagClsMytype
CString m_Name;
int m_Index;
double m_Value;
} xClsMytype;
//================ End of Type Definition for the class of ClsMytype=====================
class ClsMytype : public CObject
public:
ClsMytype(); // Constructor
virtual ~ClsMytype(); // Distructor
ClsMytype(const ClsMytype &e);//Copy Constructor
// =========================================
DECLARE_SERIAL(ClsMytype)
virtual void Serialize(CArchive& ar); /// Serialize
ClsMytype& operator=( const ClsMytype &e); //= operator for class
xClsMytype GetType(); // return the typedef struct of an object
ClsMytype& operator=( const xClsMytype &e);// = operator to use typedef struct
ClsMytype* operator->() { return this;};
operator ClsMytype*() { return this; };
//public veriable decleare
public:
CString m_Name;
int m_Index;
double m_Value;
typedef struct tagClsMyTypeCollection
vector <xClsMytype> m_t_Col;
} xClsMyTypeCollection;
class ClsMyTypeCollection : public CObject
public:
ClsMyTypeCollection(); // Constructor
virtual ~ClsMyTypeCollection(); // Distructor
ClsMyTypeCollection(const ClsMyTypeCollection &e);//Copy Constructor
DECLARE_SERIAL(ClsMyTypeCollection)
virtual void Serialize(CArchive& ar);
xClsMyTypeCollection GetType();
ClsMyTypeCollection& operator=( const xClsMyTypeCollection &e);
ClsMyTypeCollection& operator=( const ClsMyTypeCollection &e); //= operator for class
void Init(); // init all object
CString ToString(); // to convert value to string for the display or message proposed
ClsMyTypeCollection* operator->() { return this;}; // operator pointer to ->
operator ClsMyTypeCollection*() {return this;};
public:
vector <ClsMytype> m_t_Col;
//private veriable decleare
private:
//===================================================
ClsMytype& ClsMytype::operator=( const xClsMytype &e )
this->m_Name= e.m_Name;
this->m_Index= e.m_Index;
this->m_Value= e.m_Value;
return (*this);
//==========================Problem for the vector to vector cast
ClsMyTypeCollection& ClsMyTypeCollection::operator=( const xClsMyTypeCollection &e )
this->m_t_Col= (vector<ClsMytype>)e.m_t_Col; // how to cast
return (*this);
Thanks in AdvanceHi Smirt
You could do:
ClsMyTypeCollection* operator->() {
returnthis;};
// operator pointer to ->
operatorClsMyTypeCollection*()
{returnthis;};
public:
vector<ClsMytype>
m_t_Col;//??
The last line with "vector<xClsMytype>
m_t_Col;". It compiles but I doubt that is what you want.
Regards
Chong -
hi to all,
i am using a session less bean A to querry a Entity Bean B , which inturns calls another EntityBean C ,
finally a ' find' method is invoked on the EntityBean C, In this a vector is created which holds 3 different vectors at different indexes, now the problem i am facing is that when Enity Bean B is returning the final vector to the A , it's firing out a errors that :-
TRANSACTION COULD NOT BE COMPLETED: RemoteException occurred in server thread;
ested exception is:
java.rmi.RemoteException: null; nested exception is:
java.rmi.ServerException: RemoteException occurred in server thread; ne
ted exception is:
java.rmi.RemoteException: null; nested exception is:
java.io.NotSerializableException: java.util.Vector$1
java.rmi.ServerException: RemoteException occurred in server thread; nested exc
ption is:
java.rmi.RemoteException: null; nested exception is:
java.rmi.ServerException: RemoteException occurred in server thread; ne
ted exception is:
java.rmi.RemoteException: null; nested exception is:
java.io.NotSerializableException: java.util.Vector$1
java.rmi.RemoteException: null; nested exception is:
java.rmi.ServerException: RemoteException occurred in server thread; ne
ted exception is:
java.rmi.RemoteException: null; nested exception is:
java.io.NotSerializableException: java.util.Vector$1
java.rmi.ServerException: RemoteException occurred in server thread; nested exc
ption is:
java.rmi.RemoteException: null; nested exception is:
java.io.NotSerializableException: java.util.Vector$1
java.rmi.RemoteException: null; nested exception is:
java.io.NotSerializableException: java.util.Vector$1
java.io.NotSerializableException: java.util.Vector$1
<<no stack trace available>>
ur any help would be highly appricated to solve out this prob.
If i try to iterate through this vector it's gives IOR:0232003x343242344asdsd................................................blabla....................
thanxs in adavance
DeepakHi I think you are using the method elements() in a remote method.
This method can't be Serializable!! Because it returns an Interface. Interfaces are never Serializable.
Regards,
Peter -
Fetching filenames from a directory and adding to vector
Hi all,
I am seeking your help to implement a certain logic.
I have a root directory. This directory contains hundreds of folders, subfolders and files.
I have a method(getChildren(pathname)) by which I get the children names corresponding to each directory, and for this I only need to give the path of the directory to the method, which returns the children vector.
I have a method to determine whether a name in the children vector is a directory or not.
The first path ; ie; the root directory path will be "/" . After that, for each sub directory, the path will be created by appending the directory name to it. ie; /subfolder1/subfolder2..
In short, I need to iterate through the entire directories and subdirectories in the root folder, by passing the path as argument to the getChildren(pathname) method .
I add all these child names to a vector.
Can anyone kindly help me by giving suggestions, as to how can I implement this logic.
Please help.
Any help will be appreciated with dukes.
Regards,
RonyThanks veldhanas,please refer my code posted and the comments given after this.
Vector getFileListing() throws FileNotFoundException {
Vector result = new Vector();
_constructChildren(new File("/"), result);
System.out.println("result"+result);
return result;
private void _constructChildren(File dir, Vector files)
if (dir.isDirectory())
System.out.println("dir.getAbsolutePath"+dir.getAbsolutePath());
Vector children = constructChildren(/*how to generate path to be passed from here*/);
Iterator i = children.iterator();
while(i.hasNext())
SFTPv3DirectoryEntry child = (SFTPv3DirectoryEntry) i.next();
if (child.attributes.isDirectory())
_constructChildren(new File(dir, child.filename), files);
else
files.add(child);
}"How to maintain the path."
The root path(first path) will be "/" . Rest all I have to generate by appending the folder names.
This point is what puzzles me.
Once more I make my point clear. There are no methods to generate the path, instead it has to be generated manually.
The only initial path what we have is "/" . Later on path has to be generated in the format /dirname1 or /dirname1/dirname11 and the likes and load the children based on these paths and add to the result vector.
If i correctly generate the path by using the directory names in the format /.../.../.. , the constructchildren method will give the children corresponding to the path and my problem is solved!
Hope I am clear enough.
Maybe you are looking for
-
Hello to Tuttti, I'm building a site in flash: ( http://www.holidaysinlucca.it/) viewing with Internet Explorer 7 is all ok. But if I use Firefox with the latest version 3.05 and with latest flash player installed correctly you see only the page intr
-
How can i see all the songs I already purchased on my two computers. I don't have a network
how can i see all the songs I already purchased on my two computers. I don't have a network
-
R12 Database Cloning with error AC-00423 / RC-50014
Hi Friends. We have an R12.1.3 Application with 11gR2 database on a Sun Sparc solaris 10 machine. From production cold backups, we are trying to clone a new test instance. The cloning is failing while configuring Oracle Home in DB Tier. in the logs i
-
How do you flush an IP address?
I am trying to connect to a new cable modem but the IP address OS X keeps showing me in sys. prefs is incorrect so I get no connection. My local isp says it should begin with 242 and I keep getting 169.. I have tried the obvious resetting the modem,
-
Problem in check sapscripts printing
Hi friends, I am getting this error (The program attempted to interpret the value "*81145.00-" as a number, but since the value contravenes the rules for correct number formats, this was not possible.)