Using Vector in Java script

I got this vector class from some website for implementation of vector in java script
function Vector(inc) {
     if (inc == 0) {
          inc = 100;
     /* Properties */
     this.data = new Array(inc);
     this.increment = inc;
     this.size = 0;
     /* Methods */
     this.getCapacity = getCapacity;
     this.getSize = getSize;
     this.isEmpty = isEmpty;
     this.getLastElement = getLastElement;
     this.getFirstElement = getFirstElement;
     this.getElementAt = getElementAt;
     this.addElement = addElement;
     this.insertElementAt = insertElementAt;
     this.removeElementAt = removeElementAt;
     this.removeAllElements = removeAllElements;
     this.indexOf = indexOf;
     this.contains = contains
     this.resize = resize;
     this.toString = toString;
     this.sort = sort;
     this.trimToSize = trimToSize;
     this.clone = clone;
     this.overwriteElementAt;
// getCapacity() -- returns the number of elements the vector can hold
function getCapacity() {
     return this.data.length;
// getSize() -- returns the current size of the vector
function getSize() {
     return this.size;
// isEmpty() -- checks to see if the Vector has any elements
function isEmpty() {
     return this.getSize() == 0;
// getLastElement() -- returns the last element
function getLastElement() {
     if (this.data[this.getSize() - 1] != null) {
          return this.data[this.getSize() - 1];
// getFirstElement() -- returns the first element
function getFirstElement() {
     if (this.data[0] != null) {
          return this.data[0];
// getElementAt() -- returns an element at a specified index
function getElementAt(i) {
     try {
          return this.data;
     catch (e) {
          return "Exception " + e + " occured when accessing " + i;     
// addElement() -- adds a element at the end of the Vector
function addElement(obj) {
     if(this.getSize() == this.data.length) {
          this.resize();
     this.data[this.size++] = obj;
// insertElementAt() -- inserts an element at a given position
function insertElementAt(obj, index) {
     try {
          if (this.size == this.capacity) {
               this.resize();
          for (var i=this.getSize(); i > index; i--) {
               this.data[i] = this.data[i-1];
          this.data[index] = obj;
          this.size++;
     catch (e) {
          return "Invalid index " + i;
// removeElementAt() -- removes an element at a specific index
function removeElementAt(index) {
     try {
          var element = this.data[index];
          for(var i=index; i<(this.getSize()-1); i++) {
               this.data[i] = this.data[i+1];
          this.data[getSize()-1] = null;
          this.size--;
          return element;
     catch(e) {
          return "Invalid index " + index;
// removeAllElements() -- removes all elements in the Vector
function removeAllElements() {
     this.size = 0;
     for (var i=0; i<this.data.length; i++) {
          this.data[i] = null;
// indexOf() -- returns the index of a searched element
function indexOf(obj) {
     for (var i=0; i<this.getSize(); i++) {
          if (this.data[i] == obj) {
               return i;
     return -1;
// contains() -- returns true if the element is in the Vector, otherwise false
function contains(obj) {
     for (var i=0; i<this.getSize(); i++) {
          if (this.data[i] == obj) {
               return true;
     return false;
// resize() -- increases the size of the Vector
function resize() {
     newData = new Array(this.data.length + this.increment);
     for     (var i=0; i< this.data.length; i++) {
          newData[i] = this.data[i];
     this.data = newData;
// trimToSize() -- trims the vector down to it's size
function trimToSize() {
     var temp = new Array(this.getSize());
     for (var i = 0; i < this.getSize(); i++) {
          temp[i] = this.data[i];
     this.size = temp.length - 1;
     this.data = temp;
// sort() - sorts the collection based on a field name - f
function sort(f) {
     var i, j;
     var currentValue;
     var currentObj;
     var compareObj;
     var compareValue;
     for(i=1; i<this.getSize();i++) {
          currentObj = this.data[i];
          currentValue = currentObj[f];
          j= i-1;
          compareObj = this.data[j];
          compareValue = compareObj[f];
          while(j >=0 && compareValue > currentValue) {
               this.data[j+1] = this.data[j];
               j--;
               if (j >=0) {
                    compareObj = this.data[j];
                    compareValue = compareObj[f];
          this.data[j+1] = currentObj;
// clone() -- copies the contents of a Vector to another Vector returning the new Vector.
function clone() {
     var newVector = new Vector(this.size);
     for (var i=0; i<this.size; i++) {
          newVector.addElement(this.data[i]);
     return newVector;
// toString() -- returns a string rep. of the Vector
function toString() {
     var str = "Vector Object properties:\n" +
     "Increment: " + this.increment + "\n" +
     "Size: " + this.size + "\n" +
     "Elements:\n";
     for (var i=0; i<getSize(); i++) {
          for (var prop in this.data[i]) {
               var obj = this.data[i];
               str += "\tObject." + prop + " = " + obj[prop] + "\n";
     return str;     
// overwriteElementAt() - overwrites the element with an object at the specific index.
function overwriteElementAt(obj, index) {
     this.data[index] = obj;
Now I have written this code .This code is written using API'sfunction getOptions(ctx)
var options="";
var subroles = ctx.getAdminRole().getAttributeMultiValue("CUSTOM10");
var v = new Vector(subroles);
options = v.getElementAt(0);
Now suppose the function getAttributeMultivalue is returning RoleA,RoleB
Now i want RoleA to be stored in getElementAt(0) and RoleB in getElementAt(1)
But with the above code i am getting RoleA,RoleB in getElementAt(0)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

abhishek20 wrote:
well the question is also about Vector class of JavaNo it is not you doofus. It is about JavaScript. Your question has fuck all to do with Java.
so I thought to post it here.That was a mistake.
any ways if you don't know java script or anything about vector class then you should not reply.I know about JavaScript.
I know about Vectors.
I will not tell you anything about JavaScript here.
I wouldn't tell you anything useful anyway because I have taken a personal dislike to you.
>
No need to make me understand what is the purpose of this forum.Really? Because you don't seem to get it. At all.
next time take care before you reply.Next time engage your tiny pea brain in some sort of logical thought before posting.

Similar Messages

  • How to use HTML and Java Script files in Portal

    Hi,
    I am trying to access a web application using iViews. My application contains JSP,HTML,Servlets,JS(java script), image files. I am using JSPDynPro to access the JSP files and I am putting servlets in the private/lib folder of the PORTAL-INF dir of Portal project. Now my problem is almost all the JSP files uses the HTML files, JS files and image files. Where can put these files in the portal project dir structure to give access to the JSP files when i am creating a iView for the JSPDynPro componenets in the irj.
    thanks,
    Ashok

    Hi,
    JSPDynpage is the controller, one JSPDynpage can call more than one jsp file according to the coding. Through the JSPDynpage's setJspName() function only you can display a jsp page.
    EX:
    public void doProcessBeforeOutput() throws PageException {
      this.setJspName("logon.jsp");
    if you put the JSPDynpage in the src.core then the JSPDynpage can be accessed only by this application.
    if you put the JSPDynpage in the src.api then other applications can access this component.
    You can put the jsp pages in the pagelet folder.
    xml file
    =========
    <?xml version="1.0" encoding="utf-8"?>
    <application>
      <application-config>
        <property name="SharingReference" value="com.sap.portal.htmlb"/>
      </application-config>
      <components>
        <component name="jspdynpage name">
          <component-config>
            <property name="ClassName" value="package name.jspdynpagename"/>
          </component-config>
          <component-profile>
            <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
          </component-profile>
        </component>
      </components>
      <services/>
    </application>
    REWARD USEFUL ANSWERS

  • Using XML or Java Scripting

    Hello all
    i am new to obi ee and i wanna know how can we use the codes of xml and java scripting in it and i am sitting on the client system...Do i need to change some files on server???
    thanks in advance,
    pankaj

    You mean like in this thread? Re: Creating a Popup Box / List of Values on a Dashboard
    What's the idea behind it?
    Why this and not a prompt?
    Input mask for write-back?
    Cheers,
    C.

  • What can I use to view java script in my browser for iPhone

    I can't view JavaScript , what do I use instead. Java's web site says that apple has there own version but I can't find it.

    JavaScript works just fine in iOS.
    Java does not.
    They are not the same thing.

  • Validating Checkboxs in a form using java script.

    Hi i am trying to validate a jsp page that contains check-boxs using the following java script, however it doesnt seem to work! Any help on this matter would be most appreciated.
    <SCRIPT language="javaScript">
    function validate()
    if (document.myform.pkey.value=="")
    alert("Please Select a Questionnaire to delete!!");
         return false;
    </SCRIPT>

    Hi,
    You have to check whether user has selected the check box or not.
    When there are multiple check boxes with same name, it will create any array else normal single check box.
    Ajay.

  • Acrobat standard 9.0 error while enabling commets option using Java script object

    I'm using the below java script code in my VB 6.0 application for enabling commets options in the PDF file
    Dim oJSO As Object
    Set oJSO = mPDDoc.GetJSObject
    oJSO.Collab.showAnnotToolsWhenNoCollab = True
    It is working fine till Acrobat 8.0. Now I'm trying with Acrobat 9.0 standard edition, it is throwing scripting error 'An unhandled Win32 exception occured in Acrobat.exe[308].
    Can anyone suggest the way to enable 'comment' options in Acrobat Standard 9.0 using Java Script Object?
    Thanks

    I get much the same problem with VB6, Acrobat 9 Pro and WinXP SP3. When I single step the line:
    oJSO.Collab.showAnnotToolsWhenNoCollab = True
    in debug I go to the error handler for my Sub. Inspecting the VB Err object has Number = -2147417851 and Description = "Automation error
    The server threw an exception." I get a Microsoft crash notice about Acrobat a short while later.
    I've experimented with the JavaScript debugger in Acrobat and you can execute Collab.showAnnotToolsWhenNoCollab = True and reference the value of Collab.showAnnotToolsWhenNoCollab in the console. The problem appears only when accessing Acrobat Javascript through the Interapplication Communication API.
    If anyone can help it would be appreciated. I tried Adobe's Acrobat support and they were no help at all.

  • I need to write a Java script to make my Art board bigger by 1 (one) inch on the Width and Length, Regardless of the Content?

    Hi,
    I am currently using "Visible bounds" (java script)to add 1 inch to the width and to the Length of my Art board, but when i make a clipping mask it actually reads the hidden content from the Clipping mask and makes conforms my art board to that particular shape. Am using Adobe illustrator cs6 Here is My Code:
    var myDocs = app.documents;
    var i = 0;
    for (i = myDocs.length-1 ; i >= 0; i--)
        var doc = myDocs[i];
        app.activeDocument= doc;
        var myVisibleBounds = doc.visibleBounds; //Rect, which is an array;
        myVisibleBounds[0] -= 36;
        myVisibleBounds[1] += 36;
        myVisibleBounds[2] += 36;
        myVisibleBounds[3] -= 36;
        doc.artboards[0].artboardRect = myVisibleBounds;
    All i Want is to add 1 inch to my width and length and this does it but if i have a clipping mask it will pick up the bounding box i guess? and it will conform it to the shape... any help please... Try my code and you will see that it does add 1 inch but now make you artboard lest say 12" x 12" and make a shape bigger than the art board and you will see how it adds 1 inch to the art board based on that shape...  now if you make a clipping mask to fit that shape in the 12" x 12" art board you will still get 1 inch bigger than the shape thats being clipped ... 

    yes, visible bounds is reading the non-visible masked objects too.
    you're going to have to do it the hard way, loop through all your objects to get your bounds manually, and while you're at it, test for clipping masks and use the masking path instead.

  • Linking to external java script

    Is there a way to link a button in a swf to a java script. I'm trying to use the "lightbox" java script so that when a user clicks on an image in the swf, a larger image appears on top of the page. Here is what the link looks like in html:
    <a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
    Can anyone tell me how to code this in Flash?
    Thanks!

    you can use the externalinterface class in flash to call js functions in the embedding html but, i don't see any js in the code you posted.
    addendum.  you'll need to check the javascript files that use that lightbox method.

  • Rhino support for java script

    sir i have jEditorPane and i came to know that rhino.jar file can be used to support java script.
    what is the way to make the java script support on jEditorPane
    any body has code for that?

    Hi,
    true, JEE 5 support is under way..
    Have a look at <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/712eea91-0801-0010-158a-927edb8a45bd">this</a> presentation for more details about what you can expect in the next major release of NW.
    No idea about the timelines from my side as well.
    regards,
    Ivo

  • Problem while handling java script in servlet

    Hi All,
    The requirement is something like this , a pop-up window should come up in the client side
    and once the user clicks it , he/she should be redirected to a new page/link
    For this I used a small java script in my servlet,to generate a pop-up window in the client end.
    After that I tried to redirect the user to a new page. at this point I am facing difficulties
    and getting the following error message:
    java.lang.IllegalStateException: Cannot forward after response has been committed
    Please help!!

    public class test1 extends HttpServlet {
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    public static void redirect(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext, String url)
    System.out.println("Inside Utils function "+request+response+url);
    try{
    RequestDispatcher rd = null;
    System.out.println("Inside Utils function if loop "+request+response+url);
    rd = servletContext.getRequestDispatcher(url);
    rd.forward(request, response);
    catch(Exception e)
    System.out.println("Caught an exception \n\n"+e);
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    //HttpServletResponse response1 ;
    response.setContentType("text/html;charset=UTF-8");
    String s1="hai";
    System.out.println("Before code" + getServletContext() );
         PrintWriter output = response.getWriter();
    //StringBuffer output = null;
    output.println("<html>\n");
    output.println("<head>\n");
    output.println("<title>"+ "Alert window" +"</title>\n");
    output.println("<script type=\"text/JavaScript\">\n");
    output.println("          var write_\n");
    output.println("          write_ = \" alert License screen\"\n");
    output.println("          alert(write_);\n");
    output.println("\n");
    output.println("</script>\n");
    output.println("</head>\n");
    output.println("<body>\n");
    output.println("<h1>Servlet test1 at " + request.getContextPath () + "</h1>");
    System.out.println("Inside html body " + request.getContextPath () + request + response);
    //redirect(request, response, getServletContext() , "/test3" );
    output.println("</body>\n");
    output.println("</html>\n");
    output.close();
    //response.resetBuffer();
    //response.reset();
    //HttpSession httpSession = request.getSession(true);
    redirect(request, response, getServletContext() , "/test3" );
    System.out.println("After code" + request.getContextPath ());
    String s2="hello hai";
    System.out.println(s2);
    }

  • Java script documentation for DRM

    Is there a doc that shows all the property values you can use in a java script?
    How do I identify the enumeration constants?

    <body onbeforeunload="ConfirmClose()" onunload="HandleOnClose()">
    where ConfirmClose() asks you if you really want to close, and HandleOnClose() does something as you close the tab.

  • Java scripts charts

    Hi
    I have imported the SDK extension components using eclipse and i am able to call  design studio using eclipse with the downloaded custom components.
    Now i want to know wheather i can use an existing line charts code used  by  java scripts.  The same charts can i import into eclipse by using the same java scripts and  i want to know whether these charts can be pulled in design studio like sdk components.  without creating the charts in design studio can we import the charts directly using eclipse and coding is done by java scripts and called by HTML.
    Rgds
    Ramesh

    Ramesh, Mustafa and I both gave you this answer already.  Again, yes you CAN write a chart library wrapper, assuming that it uses normal JavaScript techniques and you have a license that works for your usage.
    What you cannot "simply" do is just import the JavaScript library and it work without any further effort on the SDK developer's part.  You must manually map the imported library's specific properties which vary from API to API, as well as convert the datasource bindings from Design Studio SDK structure to something that the library you choose will accept.
    You are on your own in figuring that out, I don't know of a volunteer who will spell that out for you beyond explaining what we already have at a high level design concept.  If you need a head-start with some reusable example similar to maybe what you'd like to achieve, please read this blog post, and visit the source code link contained there to get a decent idea of the work ahead of you:
    Design Studio 1.2 SDK - An adventure in creating a data bound Chart Component wrapper

  • Can we use Java Script in SAP BusinessObjects Web Intelligence 4.1?

    Can we use Java Script or any other Script in BI 4.1 Web Intelligence? If possible please do let me know the method/process

    Hi Kranthi,
    You have option to read a cell content as html. else you will have to go for SDK. I think you will get better suggestions, if you can explain your requirement in a little detailed manner.
    refer below links for more details about SDK.
    http://bukhantsov.org/2013/04/how-to-create-a-webi-document-using-java-report-engine-sdk/
    Regards,
    Nikhil Joy

  • In a Conversion file, Using Java Script - IF statement with Greater,Less definitions

    Hail to All Gurus,
    Well, I've been trying to make a conversion file by using if statement of Java script with < , > definitions. unfortunately i got "Evolution error" over and over again.
    Actually i want to convert all dates before 2009 as 2008.12. And the dates which is greater than 2009 will be converted as they are (e.g. 2009.01 or 2010.02 etc.).
    Code is:
    js:if(%external%.toString().substring(0,4)<"200900"){"2008.12"}else{%external%.toString().substring(0,4) + "." + %external%.toString().substring(4,6)}
    SAP EPM version 10.0 SP15 Patch 2
    Build 8586
    Thanks for your help in advance

    Sadi,
    You can write if Statement in transformation not conversion.
    Look at this docs,
    How to Import Master Data and Hierarchies into SAP BusinessObjects BPC 7.5 from SAP NetWeaver BW
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c02d0b47-3e54-2d10-0eb7-d722b633b72e?QuickLink=index&…
    Thanks

  • How to Use the JAVA SCRIPT code in .htm page of the component

    Hi .
    In my requirement i have to use Java Script Function in .htm code ..how to use the java script code and functions in .htm???
    thank you
    B.Mani

    Check this document  [Arun's Blog|http://wiki.sdn.sap.com/wiki/display/CRM/CRMWebClientUI-TalkingwithJava+Script]
    Regards
    Kavindra

Maybe you are looking for

  • G4 MDD/FW800: shut down and restart commands do not work

    Hey all, I've done some searching here and on the internet in general and haven't turned up anything useful. Suddenly my G4 no longer shuts down when I select "shut down" from the Apple menu. The "Restart" command also does not work. What happens is

  • What does a pop up I want to access your computer mean

    I was watching a you tube video and I received a pop up that said I want to access your computer accept or deny. I hit deny a bunch of times and it wouldnt go away. I hit accept now I wonder if I gave someone access to my computer? I have norton for

  • Wrong GL Default on PO

    Hi All, Pls advise on the below. When a Purchase Order is created off a Work Order, the system is currently determining what GL Account to default. Amount under $100 is set to GL Acct 410000 and over $100 is set to GL Acct 401200. Dollar amt under $1

  • Grep styles and bullet points

    Is there a way of using GREP styles to insert bullet points on text after a specific heading has been detected? I am working on a brochure where many of the pages will have a features section, so am reluctant to manually overide paragraph styles. The

  • Error -2147217887 occurred at DB Tools Open Connec(string).vi

    LabVIEW 7.1 with db connectivity toolkit is returning this error every few days. Error -2147217887 occurred at DB Tools Open Connec(string).vi -> ... Possible Reason(s): API Error: USER LIMIT EXCEEDED. In DB Tools Open Connec(string).vi -> ... I use