Nested vectors problem
Hi,
I'm having a bit of a problem trying to create a vector within a vector. I am parsing a string and adding the elements to a vector. Then after I've done this I want to add the newly populated vector to another vector, then clear the original vector and start again. Thus adding "rows" and "columns" to create a 2D array as a vector.
However, my problem comes when I try to clear the first vector after I've added it's contents to the containing vector. When I call the clear(); function it does clear the vector, but it also clears it from containing vector I've just added it to! Surely this can't be right? What's the way around this?
String rows = "";
Vector vCols = new Vector();
Vector vRows = new Vector(vCols);
// Split on rows
StringTokenizer stRows = new StringTokenizer(rows, "][");
//while rows remaining, put contents in vector
while (stRows.hasMoreTokens()) {
//split on ']['
//clearing this also remove the contents already put into vRows !!
vCols.clear();
rows = stRows.nextToken(); // contains A row!
StringTokenizer stCols = new StringTokenizer(rows, ",");
//now parse the columns
while (stCols.hasMoreTokens()) {
String d = stCols.nextToken();
vCols.addElement(d);
vRows.addElement(vCols);
TIA
~PAul Phillips
Use [code ] tags when pasting code to make the code readable. Click on the "Formatting Help" link before you post your next thread for more information.
You can't just 'clear' a Vector and and more data to it you need to create a new Vector for every row. This thread shows a similiar example on creating a Vector of Vectors from a ResultSet from an SQL query:
http://forum.java.sun.com/thread.jsp?forum=57&thread=497641
Similar Messages
-
Error #1034 Type Coercion fail with registerClassAlias and nested Vectors
I'm attempting to use flash.net.registerClassAlias and ByteArray.writeObject in order to serialize/deserialize data with static type information. It works as you'd expect in the general case but I've run into problems with some nested Vectors that I don't understand. Hopefully someone can point out if I'm just missing something.
For what I understand, we must register both the scalar types and a one-deep specification of a Vector for that scalar type in order to use nested Vectors. For example:
flash.net.registerClassAlias("TestStructureInner", TestStructureInner);
flash.net.registerClassAlias("VectorTestInner", Vector.<TestStructureInner> as Class);
This should allow us to read/write objects of type TestStructureInner, Vector.<TestStructureInner>, and Vector.<Vector.<TestStructureInner>> into ByteArrays. And in general it seems to work.
Attached though is a simplified test case that fails, however. The first time we deserialize the data it works. The subsequent time, however, we encounter the following runtime error #1034.
TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@304fcb9 to __AS3__.vec.Vector.<__AS3__.vec::Vector.<Test0.as$30::TestStructureInner>>.
TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@304fbc9 to __AS3__.vec.Vector.<__AS3__.vec::Vector.<Test0.as$30::TestStructureInner>>.
TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@304fdd1 to __AS3__.vec.Vector.<__AS3__.vec::Vector.<Test0.as$30::TestStructureInner>>.
TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@304fce1 to __AS3__.vec.Vector.<__AS3__.vec::Vector.<Test0.as$30::TestStructureInner>>.
TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@304fbf1 to __AS3__.vec.Vector.<__AS3__.vec::Vector.<Test0.as$30::TestStructureInner>>.
TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@304fec1 to __AS3__.vec.Vector.<__AS3__.vec::Vector.<Test0.as$30::TestStructureInner>>.
TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@304fad9 to __AS3__.vec.Vector.<__AS3__.vec::Vector.<Test0.as$30::TestStructureInner>>.
TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@304fa61 to __AS3__.vec.Vector.<__AS3__.vec::Vector.<Test0.as$30::TestStructureInner>>.
TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@304f9e9 to __AS3__.vec.Vector.<__AS3__.vec::Vector.<Test0.as$30::TestStructureInner>>.
TypeError: Error #1034: Type Coercion failed: cannot convert __AS3__.vec::Vector.<Object>@304f971 to __AS3__.vec.Vector.<__AS3__.vec::Vector.<Test0.as$30::TestStructureInner>>.
Re-registering the class aliases again via flash.net.registerClassAlias works in this test case but isn't 100% for our actual application (I'm reticent to even mention it but it seems relevant). Is there a step I'm missing here? Any light shed would be appreciated.
// mxmlc -debug Test0.as
package
import Base64; // http://code.google.com/p/jpauclair-blog/source/browse/trunk/Experiment/Base64/src/Base64.a s
import flash.net.registerClassAlias;
import flash.events.Event;
import flash.utils.ByteArray;
import flash.display.Sprite;
import flash.display.Stage;
import flash.system.System;
public class Test0 extends Sprite
static private const OPERATION_SERIALIZE:uint = 0;
static private const OPERATION_DESERIALIZE_AND_FAIL:uint = 1;
static private const OPERATION_DESERIALIZE_AND_SUCCEED:uint = 2;
static private var staticStage:Stage;
private var bar:Vector.<TestStructure>;
* common functions
static private function registerClassAliases():void
flash.net.registerClassAlias("TestStructureInner", TestStructureInner);
flash.net.registerClassAlias("VectorTestInner", Vector.<TestStructureInner> as Class);
flash.net.registerClassAlias("TestStructure", TestStructure);
static public function staticDeserialize():Object
var byteArray:ByteArray = Base64.decode("EBUAG1Rlc3RTdHJ1Y3R1cmUKEwAHZm9vEAEAH1ZlY3RvclRlc3RJbm5lcgoBEAEABAoBEAEABA oBEAEABAoBEAEABAoBEAEABAoBEAEABAoBEAEABAoBEAEABAoBEAEABA==");
byteArray.position = 0;
return byteArray.readObject();
public function Test0():void
registerClassAliases();
// Switching operation between the constants demonstrates failure/success in a couple of different ways.
// SERIALIZE is just used to prepare the base64 string for subsequent tests.
var operation:int = OPERATION_SERIALIZE_AND_FAIL;
if (operation == OPERATION_SERIALIZE)
trace("Serializing");
// outputs base64 string for subsequent tests
serialize();
else if (operation == OPERATION_DESERIALIZE_AND_FAIL)
trace("Fail case");
// perform successful one deserialization, then one failing one.
deserializeOnceThenFail();
else if (operation == OPERATION_DESERIALIZE_AND_SUCCEED)
trace("Success via re-registration");
// perform successful one deserialization, then another successful one.
deserializeOnceThenSucceed();
* serialize
// outputs base64 string we use for subsequent tests.
private function serialize():void
var baz:Vector.<TestStructure> = new Vector.<TestStructure>;
for (var i:int=0; i<10; ++i)
baz.push(new TestStructure);
var byteArray:ByteArray = new ByteArray;
byteArray.writeObject(baz);
trace(Base64.encode(byteArray));
* deserializeOnceThenFail
// perform successful one deserialization, then one failing one.
public function deserializeOnceThenFail():void
// save stage
staticStage = stage;
// the first deserialize will proceed without error.
staticDeserialize();
trace("Successful deserialize");
// add an event listener in order to invoke error on subsequent frame
stage.addEventListener(Event.ENTER_FRAME, doEnterFrameOnceThenFail);
// remove event listener and invoke again.
static private function doEnterFrameOnceThenFail(e:Event):void
staticStage.removeEventListener(Event.ENTER_FRAME, doEnterFrameOnceThenFail);
staticDeserialize();
trace("unsuccessful deserialize2");
* deserializeOnceThenSucceed
* Here, we re-call flash.net.registerClassAlias on all our class types when running.
// perform successful one deserialization, then one failing one.
public function deserializeOnceThenSucceed():void
// save stage
staticStage = stage;
// the first deserialize will proceed without error.
staticDeserialize();
trace("Successful deserialize");
// add an event listener in order to invoke error on subsequent frame
stage.addEventListener(Event.ENTER_FRAME, doEnterFrameOnceThenSucceed);
// remove event listener and invoke again.
static private function doEnterFrameOnceThenSucceed(e:Event):void
staticStage.removeEventListener(Event.ENTER_FRAME, doEnterFrameOnceThenSucceed);
registerClassAliases();
staticDeserialize();
trace("successful deserialize2");
internal class TestStructureInner
public var value:int;
internal class TestStructure
public var foo:Vector.<Vector.<TestStructureInner>> = new Vector.<Vector.<TestStructureInner>>;The error would imply that ImageAssetEvent does not inherit
DisplayEvent. Either modify the inheritance chain or listen for a
basic Event object (flash.events.Event) and cast inside the
function. -
Vector problem... Please help!
Hi,
I searched the forum but I could not get a correct answer for a vector problem I am facing. I have 2 SQL queries that are nested. Initially I tried to nest them but realized that when I close the connection to one query I cannot nest the other since the first query is closed ( blazix web server does not let you open open a wuery if you have not closed one query) Somebody had suggested to include the infor on a Vector and then reuse it. However I am not sure of how to do this.
The following is what I have so far.
<%@ page import="java.util.Vector" %>
<%
<blx:sqlQuery id="Buttons">
Select ID, Ntive, ButtonLabel ButtonLink
From Pages
</blx:sqlQuery>
<% } else { %>
<blx:sqlQuery id="Project">
Select ID, ProjectName, PLongName
From Projects
</blx:sqlQuery>
<% } %>
// now both of these queries are nested within each other to get the output.
<blx:sqlExecuteQuery resultSet="rs" queryRef="Buttons">
<%
int ID = rs.getInt("ID");
int Ntive = rs.getInt("Ntive");
String ButtonLabel=rs.getString("ButtonLabel");
String ButtonLink=rs.getString("ButtonLink");
%>
<% if (ID != 1){
if (Ntive ==1) {
Link="index.jsp?Page="+ID;
} else {
Link= ButtonLink;
%>
<LI><a href="<%=Link%">> <%=ButtonLabel%></a></LI>
<% if (ID==2) {%>
// then I start the second query projects.
<blx:sqlExecuteQuery resultSet="rs" queryRef="Project">
</blx:sqlExecuteQuery>
<% if (ID==3) %>// this is again from the first query
// here i start the second query again
//now I close the first query.
Please help me to write a Vector withnin here and to retrieve the information to be used again on the same JSP page.
Thanks!I wonder why Blazix dosnt allow multiple queries.
Here is the logic using Vectors.
<%@ page import="java.util.Vector" %>
Vector IDVector = new Vector();
Vector NtiveVector = new Vector();
Vector ButtonLabelVector = new Vector();
Vector ButtonLinkVector = new Vector();
if(whatever is the codition here)
%>
<blx:sqlQuery id="Buttons">
Select ID, Ntive, ButtonLabel, ButtonLink
From Pages
</blx:sqlQuery>
<%
else
%>
<blx:sqlQuery id="Project">
Select ID, ProjectName, PLongName
From Projects
</blx:sqlQuery>
<%
%>
<blx:sqlExecuteQuery resultSet="rs" queryRef="Buttons">
<%
IDVector.add(rs.getInt("ID"));
NtiveVector.add(rs.getInt("Ntive"));
ButtonLabelVector.add(rs.getString("ButtonLabel"));
ButtonLinkVector.add(rs.getString("ButtonLink"));
%>
//now I close the first query.
</blx:sqlQuery>
<%
for(rec=0;rec<IDVector.size();rec++)
int ID = (int) IDVector.elementAt(rec);
int Ntive = (int) NtiveVector.elementAt(rec);
String ButtonLabel = (String) ButtonLabelVector.elementAt(rec);
String ButtonLink = (String) ButtonLinkVector.elementAt(rec);
if (ID != 1)
if (Ntive ==1)
Link="index.jsp?Page="+ID;
else
Link= ButtonLink;
%>
<LI><a href="<%=Link%">> <%=ButtonLabel%></a></LI>
<%
if (ID==2)
%>
// then I start the second query projects.
<blx:sqlExecuteQuery resultSet="rs" queryRef="Project">
</blx:sqlExecuteQuery>
<%
if (ID==3)
%>
// this is again from the first query
// here i start the second query again
<%
%>
Hope it helps.
-Mak -
Hopefully someone out there can help solve this one.
How do you get a child window to automatically resize within a parent
window?
On their own both the child window and the parent window behave as
expected but once we attempt to load the child window into the parent
window the child window is sized to some unknown but excessively large
size.
Can this be solved with some creative use of parent size relationships
or do we have to programmatically size the child window?
Any help/comments/suggestions would be greatly appreciated.
Sincerely,
Sean G. GermainGlen,
Thank you for the prompt reply.
We have already done what you suggested (My explanation was not very
clear ... sorry) to no avail.
Any more takers and/or ideas anyone?
Thanks,
Sean
-----Original Message-----
From: Glen A. Whitbeck [SMTP:[email protected]]
Sent: Monday, January 26, 1998 2:47 PM
To: GERMAIN Sean
Cc: 'Forte Users Group'
Subject: Re: Nested Window Problem
You may need to dynamically tell the child window what its parent is (such
as a named grid that exists on the parent window). Setting the child
window to size to its parent should work once the child window knows who
its parent is. You should be able to put your window into that grid at
specified row and column coordinates. To reset the parent and position a
widget in a grid, you do something like the following:
<Widget>.Parent = NIL;
<Widget>.Row = 1;
<Widget>.Column = 1;
<Widget>.Parent = <TargetGrid>;
I believe that you should be able to do the same thing for a window, too
(using "Self.Window" instead of "<Widget>").
Glen
GERMAIN Sean wrote:
Hopefully someone out there can help solve this one.
How do you get a child window to automatically resize within a parent
window?
On their own both the child window and the parent window behave as
expected but once we attempt to load the child window into the parent
window the child window is sized to some unknown but excessively large
size.
Can this be solved with some creative use of parent size relationships
or do we have to programmatically size the child window?
Any help/comments/suggestions would be greatly appreciated.
Sincerely,
Sean G. Germain<< File: vcard.vcf >> -
Hi to you all,
I have built a table which retrieves data from a .jsp file by making an http request. The particular request is made every 10 seconds.
The data is read in lines and the lines are stored in a vector.
i.e. the line is: 1 34 er ty 23
where id=1
The table is built by getting the vector elements (lines). The first element of each line is the "id"(int). On the second request data might have been changed in one or more lines in the .jsp file, thus the program must identify the change(s) and update only the specific line(s) according to the "id". I tried to do something but unfortunately the program reads only the first line of the .jsp file. Can u give me any hlep. Apologies if the explanation of my problem is poor.
I am including the specific part of my code.
Thanx
public void readDataLine()
URL url;
URLConnection connection;
String inputLine;
DataInputStream inStream;
int position = -1;
int id=0;
int i=0;
String cToken;
try
url = new URL("http","127.0.0.1",80,"/clock.jsp");
connection = url.openConnection();
inStream = new DataInputStream (connection.getInputStream());
//BufferedReader br = new BufferedReader(inStream);
while (null != inStream.readLine())
String st = inStream.readLine();
System.out.println("st: " + st);
StringTokenizer tokenizer = new StringTokenizer(st, ";");
//System.out.println("The String has " + tokenizer.countTokens() + " words." );
while (tokenizer.hasMoreTokens())
cToken = tokenizer.nextToken();
data.addElement(cToken);
if (i == 0)
id = Integer.parseInt(cToken);
i++;
// Add the vector with the 16 elements to the vector of vectors.
// vLocalStore.addElement(data.clone());
//hold vector into memory
// perform the change
position = -1;
for (i=0; i<vLocalStore.size(); i++)
Vector v = (Vector) vLocalStore.elementAt(i);
if (id == ((Integer) v.firstElement()).intValue())
position = i;
break;
if (position == -1)
// this is a new element in the vector
vLocalStore.addElement(data.clone());
System.out.println("v: " + vLocalStore);
else
// this is a replacement instruction
vLocalStore.removeElementAt(position);
vLocalStore.insertElementAt(data.clone(),position);
//System.out.println("id: " + ((Integer) v.firstElement()).intValue());
System.out.println("v: " + vLocalStore);
// Clear all the 16 elements.
data.clear();
inStream.close();
} // end try
catch (IOException e)
System.err.println("I/O Exception: " + e);
catch (NoSuchElementException e)
System.err.println("No such element: " + e.getMessage());
catch (ArrayIndexOutOfBoundsException e)
System.err.println("Exception: " + e.getMessage());
catch (Exception e)
System.err.println("Exception: " + e.getMessage());
} // end readDataLineActually, I doubt it reads the first line. You've written while (null != inStream.readLine())
String st = inStream.readLine();This reads the first line, discards it, and then reads another line. What you should replace it with is String st;
while ((st = inStream.readLine()) != null)
{or, if you want to keep your scope minimal,for (String st; (st = inStream.readLine()) != null; /* do nothing*/)
{There may be other errors, but it's hard to read unformatted code. If this doesn't fix the problem, please repost the code using [code] tags. -
Hi All,
I have a update problem in nested table.
Below is my query:
CREATE OR REPLACE TYPE TRACER.SEARCH_DATA AS TABLE OF VARCHAR2(20);
UPDATE TRACER_SEARCH_SCHEDULE_LOT_NUM
SET NOT_FOUND_SOR_LOT_NUM = SEARCH_DATA(
SELECT
COLUMN_VALUE
FROM
TABLE (SELECT SORTING_LOT_NUMBER FROM TRACER_SEARCH_SCHEDULE_LOT_NUM WHERE JOB_ID = 8)
WHERE
TRIM(COLUMN_VALUE) NOT IN (SELECT DISTINCT (SORTING_LOT_NUMBER) FROM SEARCH_SCHEDULE_RESULT_LOT_NUM WHERE JOB_ID = 8)
) WHERE JOB_ID = 8;
ORA-00936: missing expression
or I try as following
DECLARE
sor_lot_num_not_found SEARCH_DATA :=
SEARCH_DATA
SELECT
FROM
TABLE (SELECT SORTING_LOT_NUMBER FROM TRACER_SEARCH_SCHEDULE_LOT_NUM WHERE JOB_ID = 8)
WHERE
TRIM(COLUMN_VALUE) NOT IN (SELECT DISTINCT (SORTING_LOT_NUMBER) FROM SEARCH_SCHEDULE_RESULT_LOT_NUM WHERE JOB_ID = 8)
BEGIN
UPDATE TRACER_SEARCH_SCHEDULE_LOT_NUM SET NOT_FOUND_SOR_LOT_NUM = sor_lot_num_not_found WHERE JOB_ID = 8;
END;
ORA-06550: line 5, column 9:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( ) - + case mod new not null others <an identifier>
table avg count current exists max min prior sql stddev sum
variance execute multiset the both leading trailing forall
merge year month DAY_ hour minute second timezone_hour
timezone_minute timezone_region timezone_abbr time timestamp
interval date
<a string literal with character set specificat
ORA-06550: line 11, column 5:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
; for and or group having intersect minus order start union
where connect
ORA-06550: line 14, column 4:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted d
I have try on the Select Statement, it work. So is it the way that I assign data from nested table and update method is wrong?
Edited by: skymonster84 on Mar 8, 2011 5:12 PMHi,
I think MULTISET operators might interest you.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/operators006.htm
Not tested :
UPDATE tracer_search_schedule_lot_num
SET not_found_sor_lot_num =
sorting_lot_number
MULTISET EXCEPT ALL
CAST(
MULTISET(
SELECT distinct sorting_lot_number
FROM search_schedule_result_lot_num
WHERE job_id = 8
AS search_data
WHERE job_id = 8
; -
Vector problem after copy/paste from Excel
In the past I've been able to drag or copy and paste an image from excel into Illustrator. I've lost that ability (sometimes I'll get a shadow image copied in, but it is not in vectors and it is not editable). If I save the figure as a PDF to copy it into Illustrator as a vector formatted object I cannot figure out how to change any formatting/colors. I can select individual bars in a bar graph, I can add an outline to them, but the option for changing the color is completely absent. I am fairly new to this, but would love help. I've tried releasing the clipping masks, but that only fills in the entire body of the chart with color. This literally all worked fine yesterday (and I can modify prior charts that I already imported with no problem). I'd love some help and feedback as I am fairly new to this and could be missing something! Thanks.
I can't get a PDF picture, ai picture, or EPS figure to post on here so I don't know how useful an image will be, but I added a jpeg that shows the shadowing I get when I copy in at times. .
-
HP Prime: how would you approach this vector problem
Given: r1 = 2i-j+k
r2 = i+3j-2k
r3 = -2i+j-3k
r4 = 3i+2j+5k
if r4 = ar1+br2+cr3 find the values for a, b, c
If I use the Solve App I have five equations with three unknowns and Solve App doesn't like that "Must select as many variables as equations" If I select five variables I get "no solution could be found"
I tried using the 'solve' function in the CAS mode, but it can only solve for ONE variable. Seems like the only way I can solve this problem is by hand??? any suggestions???Thanks for the encouragement, I wasn't so much stuck as I was trying to find out the power / limitations of the HP Prime.
I was disappointed to find out that the Prime doesn't seem to know the difference between the small letter i (alpha-Tan) and the complex i (shift-2) so that took awhile to figure out if I was making a mistake (why have two difference key stokes if they are both the same) or this was a peculiarity of the program. Equally frustrating was entering an equation using the small letter i, I could not tell if I was entering a complex number or a variable or a vector as there are so many different forms the complex number takes or I just can't tell the difference. Sometimes it is written 2+3*i; sometimes as [2 3*i];
i enter 2+3*(alpha TAN) and i get 2+3*i same results if i use (shift 2)
i enter ( 2+3*(alpha TAN)) and i get 2+3*i drops the parenthesis
i enter (2,3(alpha TAN)) and i get [2 3*i] why the change from parenthesis to brankets when brankets are used for matrices??? why the dropping of the comma??? i gather the brankets without the comma is a vector - just confusing having to enter with a comma but it is displayed without the comma - not very good reenforcement.
I enter (2,3i)*(4,5i) displays as [2 3*i]*[4 5*i] result is -120
I enter [2 3i]*[4 5i] displays as [2 3*i]*[4 5*i] result is -7, both entries on the left side look the same but the right side is different???? I have no idea what is going on here???
I enter(2+3i)*(4+5i) displays the same, result is -7+22*i
I enter 2+3i*4+5i displays as 2+3*i*4+5*i, result is 2+17*i
still confusing
anyway back to the problem - gave up on entering variables, just used the Linear Solver, columns x,y,z became a,b,c and rows 1,2,3 became i,j,k the solution (-2, 1, -3)
I tried your "Munk" , no function of that name in the catelog - didn't work....
Used M1^-1 * M2 and got the same results as I got in Linear Solver...
can you enlight me on complex numbers versus vectors versus whatever else I was entering, thanks -
VEctor: Problem in arithmetical operation
The problem with the following code is that when an element is accessed with v.elementAt() the compilation is OK. But if I try to do some arithmetic operation on the element, it won't compile, giving the message -
VectorDemo.java:36: operator * cannot be applied to java.lang.Object, int
System.out.println("Result: "+v.elementAt(3)*2);
Is it because of <Object> type declaration of Vector? If so how to do arithmetic operation with an element of a vector which may have Double, Float or Integer type of elements in the same vector?
import java.util.*;
class VectorDemo
public static void main(String args[])
Vector<Object> v=new Vector<Object>(3,2);
System.out.println("Initial size: "+v.size());
System.out.println("Initial capacity: "+v.capacity());
v.addElement(new Integer(1));
v.addElement(new Integer(2));
v.addElement(new Integer(3));
v.addElement(new Integer(4));
System.out.println("Capacity after four additions: "+v.capacity());
v.addElement(new Double(5.45));
System.out.println("Current capacity : "+v.capacity());
v.addElement(new Double(6.08));
v.addElement(new Integer(7));
System.out.println("Current capacity : "+v.capacity());
v.addElement(new Float(9.4));
v.addElement(new Integer(10));
System.out.println("Current capacity : "+v.capacity());
v.addElement(new Integer(11));
v.addElement(new Integer(12));
System.out.println("First element : "+v.firstElement());
System.out.println("Last element : "+v.lastElement());
System.out.println("Find Result: "+v.elementAt(3)); //<------ if replaced with:
//System.out.println("Find Result: "+v.elementAt(3)*2);
if(v.contains(new Integer(3)))
System.out.println("Vector contains 3.");
Enumeration vEnum=v.elements();
System.out.println("\nElements in vector: ");
while(vEnum.hasMoreElements())
System.out.println(vEnum.nextElement()+" ");
System.out.println();
}Here's the correct code.
import java.util.*;
import java.lang.Number;
class VectorDemo
public static void main(String args[])
//initial size is 3, increment is 2
String s;
int i=0;
Vector<Number> v=new Vector<Number>(3,2);
System.out.println("Initial size: "+v.size());
System.out.println("Initial capacity: "+v.capacity());
v.addElement(new Integer(1));
v.addElement(new Integer(2));
v.addElement(new Integer(3));
v.addElement(new Integer(4));
System.out.println("Capacity after four additions: "+v.capacity());
v.addElement(new Double(5.45));
System.out.println("Current capacity : "+v.capacity());
v.addElement(new Double(6.08));
v.addElement(new Integer(7));
System.out.println("Current capacity : "+v.capacity());
v.addElement(new Float(9.4));
v.addElement(new Integer(10));
System.out.println("Current capacity : "+v.capacity());
v.addElement(new Integer(11));
v.addElement(new Integer(12));
System.out.println("First element : "+v.firstElement());
System.out.println("Last element : "+v.lastElement());
System.out.println("Result: "+Integer.parseInt(v.elementAt(3).toString())*2);
if(v.contains(new Integer(3)))
System.out.println("Vector contains 3.");
//enumerate the elements in the vector.
Enumeration vEnum=v.elements();
System.out.println("\nElements in vector: ");
while(vEnum.hasMoreElements())
System.out.println(vEnum.nextElement()+" ");
System.out.println();
} -
I am using OBI 11g.
Nested aggregation is not supported in some forms in the BI Server (RPD), but appears to be possible by putting the second aggr rule in an Answers column formula or pivot view column. However, I cannot get this to work. Looks like can even be done in the RPD with aggregation based on dimensions, as long as there is a standard aggregation function on the outside of the expression.
The biggest problem with any of the above techniques is the BI Server does not push the outer aggregation rule to the DB engine (the generated SQL).
In my case, consider a Referral Fact with Customer Dim and Referral Dim. I need to get # of Referrals per customer, filter that with a case statement to "bin" 1 Referral and >1 Referral, and then get # of Customers in each bin. So the first measure aggregation looks like:
Other: COUNT (DISTINCT "Referral Key")
Customer: "SUM( CASE WHEN "Referral Key" = 1 THEN 1 ELSE 0 END )"
Or the logical measure just has the COUNT DISTINCT aggregation rule and an Answers column has the CASE statement with a SUM aggregation rule. Or use CASE WHEN "Referral Key" = 1 THEN "Customer Key" END and use COUNT DISTINCT instead of SUM.
All these appear to return correct results, but they all perform the outer aggregation in the BI Server or Pivot engine instead of pushing to the generated SQL (DB engine).
I can't find any problem in the DB Features. We are using SQL Server 2010.
Thanks in advance for help.Hi AL,
here is my requirement what i have been asked to get this output result.
i have keyfigures KF1, KF2 and total KF.
three characteristics dist,inch,load.
dist-inch-load--KF1-KF2-Total KF
5---A--010-0-----10=10
5---A--120-20----20+10=30
10--B---050-0-----50
12--C---160-60----60
13--D---270-70----70
14--E---080-0-----80
15--E---120-20----20+80=100
15--E---230-30----302080=130
KF1 is the initial volume coming from the file directily.based on this keyfigure i have to calculate KF2,Total KF.
In order to calcuate KF2 and Total KF i have some conditions.which are mentioned below;
KF2---> if load=0 then KF2=0 elseif load>0 then KF2=KF1 ;
Total KF--->if load=0 then Total KF=KF2KF1 elseif load>0 then KF2=KF2KF1
How to achieve this dynamic summation.Do i have to do nested exception aggregation based on the above three characteristics. what would be the open options.please do help me. -
Trigger, catproc.sql : ICD Vector problem, plz help
oracle 817, win2000
I accidently excuted this script
HOME\rdbms\admin\catproc.sql
while connected as system, not as sys.
Afterwards i executed it on sys (still not without errors, but alot less)
Now, the manager account is behaving rather weird. im getting alot of errors like this one trying to load some java stored procedures to the DB:
initialization complete
loading : MyRep
Error while loading MyRep
ORA-06509: PL/SQL: ICD-vector is missing for this package
ORA-06512: at "SYSTEM.DBMS_LOB", line 492
ORA-06512: at line 1
Obviously i've messed with something i shouldnt mess with.. how can i resolve it short of a reinst of 817 ?
Thx in advance.
nullBruce,
I think what happened is that you should have logged in as
sys instead of system when you run the catproc.sql. So, now you
have a package created for sys and system. What I suggest to you
is that you go into DBA Studio and remove the package(s)
(duplicate ones) and then you should be alright. I hope this
will solve your problem.
Steve Siew -
Hi,
I have an application with one main controller and some nested subcontrollers.
On the main page I have <bsp:call> to subcontroler 1, and on the page controlled by subcontroller 1 I have another <bsp:call> to subcontroller 2.
The problem is that when I trigger an event on the page controlled by subcontroller 2 the request is not catched by the do_handle_event of subcontroller 2.
I have dispatch_input() in do_request of main controller and nowhere else.
My application is stateful.
Does anyone know how to build application with nested controllersYou <b>need not</b> to have dispatch_input() in all the subcontroller..
In Main Controllers DO_INIT() method: You need to attach the subcontroller:
sub_cont1 ?=
create_controller( controller_name = 'list.do'
controller_id = 'List' ).
sub_cont2 ?=
create_controller( controller_name = 'control.do'
controller_id = 'Detail_Long_Id' ).
Look at the SAP standard BSP Application <b>BSP_MODEL</b>. You will get the clear idea..
Raja T -
Hi All,
I have a nested Repeater structure (please see attached
code). There is an outer Repeater which contains a VBox with
another inner Repeater inside that. I add items one at a time to
the Repeaters to create a tree like structure that should look
like:
Outer0
Inner0
Inner1
Outer1
Inner0
Inner1
If the outer Repeater is set with recycleChildren="true"
then the inner Repeater data is shown incorrectly, specifically it
looks like:
Outer0
Inner0
Inner0 (Should be Inner1)
Outer1
Inner0
Inner1
If the VBox between the outer and inner Repeaters is removed
then the Repeaters work correctly.
I believe there is a problem here in that when a Repeater
recycles it's components it checks to see if each component is also
a [nested] Repeater and if so it executes that Repeater. However,
if the nested/inner Repeater is not a direct descendent of the
outer Repeater (ie. in this example there is a VBox between the
inner and outer Repeaters) then any [grand]child Repeaters are not
executed.
Has anyone else come across this? Am I doing something wrong
and/or is there a workaround? I may be able to fix it if I can
force the Repeater to execute, but unfortunately the execute method
is private.
Incidentally, I do not want to set recycleChildren to false
as this causes a flicker, and I need the VBox inbetween for layout
purposes.
Thanks a lot,
Chris.
----Hi Chris,
I was excited when I see your question because I am having the same issue now, but I was turned down when there is no reply to your questions. Do you happen to solve this issue after all? Your feedback will be appreciated! Thanks in advance! -
Hi,
I was wondering if anyone could shed some light on this problem, I've been tearing my hair out all day.
I have a mouselistener capturing points, and the listener should add the points to a vector. The command line output is adding the 1st element once, the second element twice and so on. So the index is increasing, but the point is added a multiple of the index.
This sets up the vector and index in the method that sets up the JFrame:
nodes = new Vector();
index = 0;This is my problem method:
public void mouseClicked(MouseEvent e){
int x = e.getX(); //captures the point
int y = e.getY();
if (point == null) {
point = new Point(x, y);
} else {
point.x = x;
point.y = y;
repaint();
nodes.add(index,point); // adds the point to the vector
index++; //vector index
System.out.println(nodes); //prints the contents
System.out.println(nodes.size()); //prints length of vector
} Example output:
[Java.awt.Point[x=10,y=10]],
1
[Java.awt.Point[x=20,y=20],[Java.awt.Point[x=20,y=20]]
2
[Java.awt.Point[x=30,y=30],[Java.awt.Point[x=30,y=30],[Java.awt.Point[x=30,y=30]]
3The command line output is adding the 1st element once, the second element twice and so on.I really don't know waht you mean by that. It would have been great to see some output that you wish would be.
I'll give it a shot though. And please correct me on my assumptions.
First, Vector.add(int index, Object obj) method inserts objects at specified index, nothing more.
On the other hand, Vector.add(Object obj) method appends objects at the end of Vector.
Second, you are creating one and only one Point object in the entire execution.
When you reset the x y attributes of your object, this does not create another one.
So if you want different objects in the Vector, you must create one at each mouseClicked() call.
My assumption is that you are trying to achieve this, for instance at index 3:
[Java.awt.Point[x=10,y=10],[Java.awt.Point[x=20,y=20],[Java.awt.Point[x=20,y=20],[Java.awt.Point[x=30,y=30],[Java.awt.Point[x=30,y=30],[Java.awt.Point[x=30,y=30]]
3
If so, then you should do:
public void mouseClicked(MouseEvent e) {
int x = e.getX(); //captures the point
int y = e.getY();
Point point = new Point(x, y);
repaint();
for (int i = 0; i <= index; i++)
nodes.add(point); // adds the point to the vector
index++; //vector index
System.out.println(nodes); //prints the contents
System.out.println(nodes.size()); //prints length of vector
}I may be flat wrong with that assumtion. If this is the case please repost clearer specs of what the output should look like. -
I'm creating a vector from a recordset, which i will use for paging purposes. I searched the posts for this but didn't find any good answers. Anyway, here's what I have. It's all in the JSP page (at least for now):
Vector dataVector = new Vector();
Vector rowVector;
ResultSetMetaData rsmd = rset.getMetaData();
int count = rsmd.getColumnCount();
while (rset.next() ) {
rowVector = new Vector();
for (int i = 1; i <= count ; i++) {
rowVector.addElement(rset.getObject(i));
dataVector.addElement(rowVector);
%>
// HTML STUFF
<%
for(int a = 0; a <= dataVector.size(); a++) { %>
<p> <%= dataVector.elementAt(a) %> </p>
<% } %>
And I get the following error:
java.lang.ArrayIndexOutOfBoundsException: 2 >= 2
at java.util.Vector.elementAt(Vector.java:417)
at org.apache.jsp.untitled$jsp._jspService(untitled$jsp.java:116)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107........
I'm selecing 3 columns from the DB table, for a total of 2 records pulled (It's a test platform). So, any ideas?
Thanks
Mike Gernhardtsize will return the total number of objects within the vector and not the max index of the vector.
a <= dataVector.size(); a++) { %>
will obviously throw a runtime exception(
java.lang.ArrayIndexOutOfBoundsException)
making it a<dataVector.size(); a++) { %> will take care of the problem.
Maybe you are looking for
-
JTable :Setting the cell renderer overrides default behaviour
I have a class renderer as shown below. I would like to apply this renderer to my cells in my JTable (see below): When I use "setDefaultRenderer" I get the behaviour I expect. Fx. that number columns a right aligned, dates show as dates etc. However
-
I just purchased and downloaded a book to my itunes library on my laptop. How do I upload it to my itouch?
-
I deleted my iphotos app off my mac by mistake. i was wondering if there is a way for me to download it for free instead having to pay for it off of appstore?
-
Captured web page has truncated text
Using Acrobat X Pro (10.1.3). When I use the Create > Create PDF from Web Page function for some URLs, I sometimes get whole sections of truncated text. Ironically, this happens on Adobe's Acrobat support forum. Deselecting the "Scale Wide Contents t
-
Hello, I`m in an evaluation process about the different EAI-Tools for my thesis. Currently I am researching about SAPs solution. So does anybody here has experience with the integration of applications (favoured heterogenous SAP/non-SAP-systems) usin