AppleScript Class recognition and Array count

I have an application "SolarMaxOsX" written in Obj C
This app is scriptable
I have a class named Ups and in Ups.m I have written  following methods:
- (id)init {
    self = [super init];
    NSLog(@"Init Ups at %p", self);
    self.upsName = [NSString stringWithFormat:@"S2000"];
//    upsPort = [NSNumber numberWithInteger:1];
    self.upsPort = 1;
    self.upsIpAddress= [NSString stringWithFormat:@"192.168.10.101"];
    self.upsDataListToDisplayInTable = [self fillUpsListDictionary];
    _uniqueID = [[NSUUID UUID] UUIDString];
    return self;
/* For appleScript recognition */
- (BOOL)application: (NSApplication *)  sender delegateHandlesKey:(NSString *)key   {
    if ([key isEqualToString: @"Ups"]) return YES;
    if ([key isEqualToString: @"upsDescriptionDict"]) return YES;
    if ([key isEqualToString: @"networkStatus"]) return YES;
    if ([key isEqualToString: @"networkOk"]) return YES;
    return NO;
- (NSUniqueIDSpecifier *)objectSpecifier {
    NSScriptClassDescription *appDescription = (NSScriptClassDescription *)[NSApp classDescription];
    return [[NSUniqueIDSpecifier alloc] initWithContainerClassDescription:appDescription containerSpecifier:nil key:@"Ups" uniqueID:self.uniqueID];
In AppDelegate.m:
There is an array : Upss declared as follows:
NSArray (Upss *) Ups; declared and initialised in AppDelegate.m file
self.Upss = [self initUpss];
sdef file for SolarMax Suite follows (compiles correctly)
<suite name="SolarMax Suite" code="SMap" description="Apple Events supportés par l&apos;application SolarMaxMain">
<class name="Ups" code="SCup" description="An object UPS in SolarMaxOsX." >
<cocoa class="Ups" inherits="item" plural="Upss"/>
<property name="id" code="ID  " type="text" access="r" description="The unique identifier of the note.">
<cocoa key="uniqueID"/>
</property>
</class>
<element description="List of Ups" type="Ups">
<cocoa key="Upss"/>
</element>
<class name="AppDelegate" code="SCad" description="main class in SolarMaxOsX.">
<cocoa class="AppDelegate" />
// Liste des Ups reconnus dans le fichier de configuration
<property name="Upss" code="SMno" type="Ups" access="r">
<cocoa key="Upss"/>
</property>
</class>
</suite>
I want to get a count for array Upss
Script follows
tell application "/Users/guydesbief/Library/Developer/Xcode/DerivedData/SolarMaxOsX-cgcuhyptmpmtiegixfnbbhpexjhn/Build/Products/Debug/SolarMaxOsX.app" to activate
-- delay 30
tell application "/Users/guydesbief/Library/Developer/Xcode/DerivedData/SolarMaxOsX-cgcuhyptmpmtiegixfnbbhpexjhn/Build/Products/Debug/SolarMaxOsX.app"
    --    set nomAppli to the name of application
    --    set theWindows to windows
    set NbWin to the count of windows
    set theWindow to first item of windows
    properties of the theWindow
    tell window "UPS Sumary"
        --click on "Statistics button"
        -- click  on button 1 of theWindow
        --        set enabled of button1 to true
    end tell
    --class of Upss
    count of Upss
end tell
I get the following answers:
tell application "SolarMaxOsX"
    activate
    count every window of current application
        --> 1
    get item 1 of every window
        --> window id 3113
    get properties of window id 3113
        --> {closeable:true, zoomed:false, class:window, index:1, visible:true, name:"UPS Sumary", miniaturizable:true, id:3113, miniaturized:false, resizable:true, bounds:{1485, 31, 1985, 579}, zoomable:true}
    count every Ups of current application
        --> error number -1728
Résultat :
error "Erreur dans SolarMaxOsX : Il est impossible d’obtenir every Ups." number -1728 from every Ups
What do I have missed ?
Logiciel  OS X 10.9.5 (13F34) (Mavericks)
Xcode Version 6.1 (6A1052d)
Éditeur AppleScript Version 2.6.1 (152.1)
AppleScript 2.3.2

Hi Hiroto
It is much better thanks
Now count of onduleurs works
Hi Hiro,
It is much better Thanks for your help
Now, count od onduleurs works
tell application "/Users/guydesbief/Library/Developer/Xcode/DerivedData/SolarMaxOsX-cgcuhyptmpmt iegixfnbbhpexjhn/Build/Products/Debug/SolarMaxOsX.app" to activate
-- delay 30
tell application "/Users/guydesbief/Library/Developer/Xcode/DerivedData/SolarMaxOsX-cgcuhyptmpmt iegixfnbbhpexjhn/Build/Products/Debug/SolarMaxOsX.app"
       --    set nomAppli to the name of application
       --    set theWindows to windows
       class of onduleurs
       count of onduleurs
       --    get properties
       set NbWin to the count of windows
       set theWindow to first item of windows
       properties of the theWindow
       tell window "UPS Sumary"
             --click on "Statistics button"
             -- click  on button 1 of theWindow
             --           set enabled of button1 to true
       end tell
       get properties
       get id of first onduleur of onduleurs
The results in appleScript:
tell application "SolarMaxOsX"
         activate
         get class of every onduleur
                 --> {onduleur, onduleur, onduleur}
         count every onduleur of current application
                 --> 3
         count every window of current application
                 --> 1
         get item 1 of every window
                 --> window id 9796
         get properties of window id 9796
                 --> {closeable:true, zoomed:false, class:window, index:1, visible:true, name:"UPS Sumary", miniaturizable:true, id:9796, miniaturized:false, resizable:true, bounds:{30, 28, 530, 576}, zoomable:true}
         get properties
                 --> error number -10000
Résultat :
error "Erreur dans SolarMaxOsX : Le gestionnaire AppleEvent a échoué." number -10000
And the results of my logging in Objective C debugger:
My sdef file
2014-12-01 23:56:36.040 SolarMaxOsX[37551:303] Appdelegate handles onduleursArray
2014-12-01 23:56:36.040 SolarMaxOsX[37551:303] handles onduleursArray OK
2014-12-01 23:56:36.041 SolarMaxOsX[37551:303] Appdelegate handles onduleursArray
2014-12-01 23:56:36.041 SolarMaxOsX[37551:303] handles onduleursArray OK
2014-12-01 23:56:36.042 SolarMaxOsX[37551:303] Appdelegate handles orderedWindows
2014-12-01 23:56:36.042 SolarMaxOsX[37551:303] Appdelegate handles orderedWindows
2014-12-01 23:56:36.043 SolarMaxOsX[37551:303] Appdelegate handles orderedWindows
2014-12-01 23:56:36.043 SolarMaxOsX[37551:303] Appdelegate handles orderedWindows
2014-12-01 23:56:36.044 SolarMaxOsX[37551:303] Appdelegate handles scriptingProperties
2014-12-01 23:56:36.044 SolarMaxOsX[37551:303] Appdelegate handles classCode
2014-12-01 23:56:36.044 SolarMaxOsX[37551:303] Appdelegate handles onduleursArray
2014-12-01 23:56:36.045 SolarMaxOsX[37551:303] handles onduleursArray OK
2014-12-01 23:56:36.045 SolarMaxOsX[37551:303] Appdelegate handles terminologyVersion
2014-12-01 23:56:36.045 SolarMaxOsX[37551:303] Appdelegate handles version
2014-12-01 23:56:36.045 SolarMaxOsX[37551:303] Appdelegate handles name
2014-12-01 23:56:36.045 SolarMaxOsX[37551:303] Appdelegate handles isActive
2014-12-01 23:56:36.046 SolarMaxOsX[37551:303] An exception was thrown during execution of an NSScriptCommand...
2014-12-01 23:56:36.046 SolarMaxOsX[37551:303] Error while returning the result of a script command: the result object...
classCode = 1667330160;
isActive = 1;
name = SolarMaxOsX;
onduleursArray =     (
"<Ups: 0x6000002c0bd0>",
"<Ups: 0x6100002c24c0>",
"<Ups: 0x6000000df100>"
terminologyVersion = 1;
version = "1.1";
...could not be converted to an Apple event descriptor of type 'application properties'. The 'onduleursArray' entry could not be converted to an Apple event descriptor of type 'onduleur'. This instance of the class '__NSArrayM' returned nil when sent -objectSpecifier (is it not overridden?) and there is no coercible type declared for the scripting class 'onduleur'.
It seems that my objectSpecifier method in Ups Category (or Ups class) is never called
My sdef File:
    <!-- Suite Solar Max -->
    <suite name="SolarMax Suite" code="SMap" description="Apple Events supportés par SolarMaxOsX">
        <!-- suppress warning for missing "savable file format" type -->
        <enumeration name="savable file format" code = "savf" hidden="yes">
            <enumerator name= "dummy" code="VTdm"
            description="A dummy file format."/>
        </enumeration>
        <class name="application" code="capp" description="SolarMaxOsX’s top level scripting object." plural="applications" inherits="application">
            <cocoa class="NSApplication"/>
<element type="onduleur" access="r">
                    <cocoa key="onduleursArray"/>
            </element>
            <property name="onduleurs" code="SMor" description="Array of onduleurs." access="r">
                <type  type="onduleur" list="yes"/>
            <cocoa key="onduleursArray"/>
            </property>
            <property name="name" code="pnam" description="The name of the application." type="text" access="r"/>
            <property name="frontmost" code="pisf" description="Is this the frontmost (active) application?" type="boolean" access="r">
                <cocoa key="isActive"/>
            </property>
            <property name="version" code="vers" description="The version of the application." type="text" access="r"/>
            <property name="terminology version" code="TEvn" type="integer" access="r">
                <cocoa key="terminologyVersion"/>
            </property>
        </class>
<class name="onduleur" code="SCup" description="An object onduleur in SolarMaxOsX." plural="onduleurs">
            <cocoa class="Ups" inherits="item" />
            <property name="id" code="ID  " type="text" access="r" description="The unique identifier of the onduleur">
                <cocoa key="uniqueID"/>
            </property>
            <property name="OnduleurName" code="pnam" description="The onduleur name. ." type="text">
                <cocoa key="name"/>
            </property>
       </class>
        // Class SolarMaxOsX to access to first window
        <class name="SolarMaxOsX" code="SMos" description="main window in SolarMaxOsX.">
        <cocoa class="SolarMaxOsX" />
</class>
    </suite>
Categories for all classes in he same file: AppDelegate+AppleScriptExtensions.m (category file)
//  SolarMaxOsX+AppleScriptExtensions.m
//  SolarMaxOsX
//  Created by  Guy DESBIEF on 28/11/2014.
#import "AppDelegate+AppleScriptExtensions.h"
#import "Ups.h"
@implementation NSObject (MNscriptability)
- (void) returnError:(int)n string:(NSString*)s {
    NSScriptCommand* c = [NSScriptCommand currentCommand];
    [c setScriptErrorNumber:n];
    if (s)
        [c setScriptErrorString:s];
@end
@implementation AppDelegate (AppleScriptExtensions)
#define APPLESCRIPT_TERMINOLOGY_VERSION 1
#pragma mark ACCESSOR METHODS
-(NSNumber *) terminologyVersion {
    return [NSNumber numberWithInt:APPLESCRIPT_TERMINOLOGY_VERSION];
// For appleScript recognition
-(NSUInteger) countOfOnduleursArray
    MyLog(@"countOfOnduleursArray");
    return [self.onduleursArray count];
- (Ups *) objectInOnduleursArrayAtIndex : (int) index {
    MyLog(@"objectInOnduleursArrayAtIndex %index", index);
     Ups *upsItem = [self.onduleursArray objectAtIndex:index];
    if (upsItem != nil)
        return upsItem;
    } return nil;
- (Ups *) valueInOnduleursArrayAtIndex:(unsigned int)i {
    MyLog(@"valueInOnduleursArrayAtIndex %i", i);
    if (![[NSScriptCommand currentCommand] isKindOfClass:[NSExistsCommand class]])
        if (i >= [onduleursArray count]) {
            [self returnError:errAENoSuchObject string:@"No such Ups."];
            return nil;
    MyLog(@"valueInOnduleursArrayAtIndex index OK: %i", i);
    return [onduleursArray objectAtIndex: i];
- (BOOL)application: (NSApplication *)  sender delegateHandlesKey:(NSString *)key   {
     MyLog(@"Appdelegate handles %@",key);
    if ([key isEqualToString: @"terminologyVersion"]) return YES;
     if ([key isEqualToString: @"onduleursArray"]) {
       MyLog(@"handles %@ OK",key);
     return YES;
    return NO;
@end
@implementation Ups (AppleScriptExtensions)
- (NSUniqueIDSpecifier *) objectSpecifier
    MyLog(@"objectSpecifier (UPS) OK");
    return [[NSUniqueIDSpecifier allocWithZone:[self  zone]]
            initWithContainerClassDescription: (NSScriptClassDescription *)[NSApp classDescription]
            containerSpecifier: nil
            key: @"onduleursArray"
            uniqueID: uniqueID];
@end
AppDelegate+AppleScriptExtensions.h (category file)
// SolarMaxOsX+AppleScriptExtensions.h
//  SolarMaxOsX
//  Created by  Guy DESBIEF on 28/11/2014.
#import <Foundation/Foundation.h>
#import "AppDelegate.h"
@class AppDelegate;
@class Ups;
@interface NSObject (MNscriptability)
- (void) returnError:(int)n string:(NSString*)s;
@end
@interface AppDelegate  (AppleScriptExtensions)
#ifdef NDEBUG
#define MyLog(f, ...)
#else
#define MyLog(f, ...) NSLog(f, ## __VA_ARGS__)
#endif
- (BOOL)application: (NSApplication *)  sender delegateHandlesKey:(NSString *)key;
- (NSUInteger) countOfOnduleursArray;

Similar Messages

  • Re: Beginner needs help using a array of class objects, and quick

    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ? In html, I assume. How did you generate the html code of your three classes ? By help of your IDE ? NetBeans ? References ?
    I already posted my question with six source code classes ... in text mode --> Awful : See "Polymorphism did you say ?"
    Is there a way to discard and replace a post (with html source code) in the Sun forum ?
    Thanks for your help.
    Chavada

    chavada wrote:
    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.You think she's still around almost a year later?
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ?Just use [code] and [/code] around it, or use the CODE button
    [code]
    public class Foo() {
      * This is the bar method
      public void bar() {
        // do stuff
    }[/code]

  • Performance of System.arraycopy and Arrays.fill

    I have some code where I call a function about 1,000,000 times. That function has to allocate a small array (around 15 elements). It would be much cheaper if the client could just allocate the array one single time outside of the function.
    Unfortunately, the function requires the array to have all of its elements set to null. With C++, I would be able to memset the contents of the array to null. In Java, the only methods I have available to me are System.arraycopy() and Arrays.fill().
    Apparently, Arrays.fill() is just a brain-dead loop. It costs more for Arrays.fill() to set the elements to null than it does to allocate a new array. (I'm ignoring possible garbage collection overhead).
    System.arraycopy is a native call (that apparently uses memcpy). Even with the JNI overhead, System.arraycopy runs faster than Arrays.fill(). Unfortunately, it's still slower to call System.arraycopy() than it is to just allocate a new array.
    So, the crux of the problem is that the heap allocations are too slow, and the existing means for bulk setting the elements of an array are even slower. Why doesn't the virtual machine have explicit support for both System.arraycopy() and Arrays.fill() so that they are performed with ultra-efficient memsets and memcpys and sans the method call and JNI overhead? I.E. something along the lines of two new JVM instructions - aarraycpy/aarrayset (and all of their primitive brethern).
    God bless,
    -Toby Reyelts

    A newly allocated array begins its life with null in its elements. There is no need to fill it with null.
    As Michael already stated, I'm not redundantly resetting all of the elements to null. Here's some code that demonstrates my point. You'll have to replace my PerfTimer with your own high performance timer. (i.e. sun.misc.Perf or whatever) Also note that the reason I'm only allocating half the array size in allocTest is to more accurately model my problem. The size of the array I need to allocate is variable. If I allocate the array outside of the function, I'll have to allocate it at a maximum. If I allocate inside the function, I can allocate it at exactly the right size.import java.util.*;
    public class AllocTest {
      private static final int count = 100000;
      public static void main( String[] args ) {
        for ( int i = 0; i < 10; ++i ) {
          allocTest();
        double allocStartTime = PerfTimer.time();
        allocTest();
        double allocTime = PerfTimer.time() - allocStartTime;
        for ( int i = 0; i < 10; ++i ) {
          copyTest();
        double copyStartTime = PerfTimer.time();
        copyTest();
        double copyTime = PerfTimer.time() - copyStartTime;
        for ( int i = 0; i < 10; ++i ) {
          fillTest();
        double fillStartTime = PerfTimer.time();
        fillTest();
        double fillTime = PerfTimer.time() - fillStartTime;
        System.out.println( "AllocTime (ms): " + allocTime / PerfTimer.freq() * 1000 );
        System.out.println( "CopyTime (ms): " + copyTime / PerfTimer.freq() * 1000 );
        System.out.println( "FillTime (ms): " + fillTime / PerfTimer.freq() * 1000 );
      private static void allocTest() {
        for ( int i = 0; i < count; ++i ) {
          Object[] objects = new Object[ 8 ];
      private static void copyTest() {
        Object[] objects = new Object[ 15 ];
        Object[] emptyArray = new Object[ 15 ];
        for ( int i = 0; i < count; ++i ) {
          System.arraycopy( emptyArray, 0, objects, 0, emptyArray.length );
      private static void fillTest() {
        Object[] objects = new Object[ 15 ];
        for ( int i = 0; i < count; ++i ) {
          Arrays.fill( objects, null );
    }I getH:\>java -cp . AllocTest
    AllocTime (ms): 9.749283777686829
    CopyTime (ms): 13.276827082771694
    FillTime (ms): 16.581995756443906So, to restate my point, all of these times are too slow just to perform a reset of all of the elements of an array. Since AllocTime actually represents dynamic heap allocation its number is good for what it does, but it's far too slow for simply resetting the elements of the array.
    CopyTime is far too slow for what it does. It should be much faster, because it should essentially resolve to an inline memmove. The reason it is so slow is because there is a lot of call overhead to get to the function that does the actual copy, and that function ends up not being an optimized memmove. Even so, one on one, System.arraycopy() still beats heap allocation. (Not reflected directly in the times above, but if you rerun the test with equal array sizes, CopyTime will be lower than AllocTime).
    FillTime is unbelievably slow, because it is a simple Java loop. FillTime should be the fastest, because it is the simplest operation and should resolve to an inline memset. Fills should run in single-digit nanosecond times.
    God bless,
    -Toby Reyelts

  • Loops and Arrays help

    Hi,
    I'm a freshman in college and new to java. I am completely lost and really need help with a current assignment. Here are the instructions given by my teacher...
    Building on provided code:
    Loops and Arrays
    Tracking Sales
    Files Main.java and Sales.java contain a Java application that prompts for and reads in the sales for each of 5 salespeople in a company. Files Main.java and Sales.java can be found here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Main.java
    and here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Sales.java It then prints out the id and amount of sales for each salesperson and the total sales. Study the code, then compile and run the program to see how it works. Now modify the program as follows:
    1. (1 pts) Compute and print the average sale. (You can compute this directly from the total; no new loop is necessary.)
    2. (2 pts) Find and print the maximum sale. Print both the id of the salesperson with the max sale and the amount of the sale, e.g., "Salesperson 3 had the highest sale with $4500." Note that you don't necessarily need another loop for this; you can get it in the same loop where the values are read and the sum is computed.
    3. (2 pts) Do the same for the minimum sale.
    4. (6 pts) After the list, sum, average, max and min have been printed, ask the user to enter a value. Then print the id of each salesperson who exceeded that amount, and the amount of their sales. Also print the total number of salespeople whose sales exceeded the value entered.
    5. (2 pts) The salespeople are objecting to having an id of 0-no one wants that designation. Modify your program so that the ids run from 1-5 instead of 0-4. Do not modify the array-just make the information for salesperson 1 reside in array location 0, and so on.
    6. (8 pts) Instead of always reading in 5 sales amounts, allow the user to provide the number of sales people and then create an array that is just the right size. The program can then proceed as before. You should do this two ways:
    1. at the beginning ask the user (via a prompt) for the number of sales people and then create the new array
    2. you should also allow the user to input this as a program argument (which indicates a new Constructor and hence changes to both Main and Sales). You may want to see some notes.
    7. (4 pts) Create javadocs and an object model for the lab
    You should organize your code so that it is easily readable and provides appropriate methods for appropriate tasks. Generally, variables should have local (method) scope if not needed by multiple methods. If many methods need a variable, it should be an Instance Variable so you do not have to pass it around to methods.
    You must create the working application and a web page to provide the applications information (i.e., a page with links to the source code, the javadoc and an object model) to get full credit. You can use the example.html's from the last two labs to help you remember how to do this.
    I'm not asking for someone to do this assignment for me...I'm just hoping there is someone out there patient and kind enough to maybe give me a step by step of what to do or how to get started, because I am completely lost from the beginning of #1 in the instructions.
    Any help would be much appreciated! Thank you!
    Message was edited by:
    Scott_010
    Message was edited by:
    Scott_010

    First ask the person who gave this asignment as to why do you require two classes for this , you can have only the Sales.java class with main method in it . Anyways.
    Let Main.java have a main method which instanciates a public class Sales and calls a method named say readVal() in Sales class.
    In the readVal method of sales class define two arrays i.e ids and sales. Start prompting the user for inputting the id and sales and with user inputting values keep storing it in the respective arrays .. Limit this reading to just 5 i.e only 5 salesPerson.
    Once both the arrays are populated, call another method of Sales class which will be used for all computations and output passing both the arrays.
    In this new method say Compute() , read values from array and keep calculating total,average and whatever you want by adding steps in just this loop. You can do this in readval method too after reading the values but lets keep the calculation part seperate from input.
    You must create the working application and a web page to provide the applications information (i.e., a page with links to the source code, the javadoc and an object model) to get full credit. You can use the example.html's from the last two labs to help you remember how to do this. I think this is ur personal stuff , but if you want to use web page , you probably will require to use servlet to read values from the html form passed to the server.

  • Problem with Java Clasess and Arrays

    Hello, i have a situation when a need to call a web services.
    I have 3 classes..and a need to call a method
    Class1 have a method
    public void setIva(ArrayOfAlicIva value)
    Class ArrayOfAlicIva is
    protected List<AlicIva> alicIva;
    This class not have a metho to set de object
    and
    Class AlicIva have 1 attributes call base int and method setBase
    When imported to Forms, i have the package with this clasess...
    The problem is when i have to call a SetIva Method.
    In pl/sql i have
    Case 1
    OraAlicIva := AlicIva.new(); --OK
    AlicIva.setBase(OraAlicIva , 10); --OK
    Class1.setIva(Object_to_Class1, OraAlicIva); --Error, is not type excpected
    Case 2
    OraAlicIva := ArrayOfAlicIva.new(); --OK
    AlicIva.setBase(OraAlicIva , 10); --Error, setBase is not defined
    Class1.setIva(Object_to_Class1, OraAlicIva); --OK
    Case 3
    OraAlicIva := AlicIva.new(); --OK
    OraAlicIva2 :=ORA_JAVA.NEW_OBJECT_ARRAY(1,'ArrayOfAlicIva'); --OK
    AlicIva.setBase(OraAlicIva , 10); --OK
    ORA_JAVA.SET_OBJECT_ARRAY_ELEMENT(OraAlicIva2 , 0, OraAlicIva); --Error, ExceptionStoreArray
    Class1.setIva(Object_to_Class1, OraAlicIva); --OK
    The Solutions in Java is
    AlicIva[] alicIva = new AlicIva[1];
    alicIva[0]= new AlicIva();
    alicIva[0].setId(Short.parseShort(1));                
    fedr[0].setIva(alicIva);}
    Is posible to Resolve ??
    Thanks and Sorry for my inglish

    Thanks for the answer but the problem is the type of object of method and how from pl/sql is posiblle to call.
    The method waiting a ArrayofAlicIva, but if i define this object is not posible to set the object inside the array because the wsdl not have this functions.
    I need to define array of objects but the object is inside is the diferent type of array.
    If i Define the array of object correct to object inside, the method expect that the other array type.
    Is a Deadlock ??
    The solution in Java is Simple
    AlicIva[] alicIva = new AlicIva[1];
    alicIva[0]= new AlicIva();
    alicIva[0].setId(Short.parseShort(1));
    fedr[0].setIva(alicIva);
    this is the method imported in java class to form
    -- Method: setIva (LArrayOfAlicIva;)V
    PROCEDURE setIva(
    obj ORA_JAVA.JOBJECT,
    a0 ORA_JAVA.JOBJECT) IS
    BEGIN
    args := JNI.CREATE_ARG_LIST(1);
    JNI.ADD_OBJECT_ARG(args, a0, 'ArrayOfAlicIva');
    JNI.CALL_VOID_METHOD(FALSE, obj, 'FECAEDetRequest', 'setIva', '(LArrayOfAlicIva;)V', args);
    END;

  • Class Composition with Array's - New to Java

    Greetings.
    I have the basic foundtion to my program laid and it seems to be doing what i need it to. However in my transaction method I have an "If" statement that is supposed to process a transaction differently based on the type of member. Based on what I have done the program operates fine if I make member type static. I will include the areas of code that refer to the problem of the member type and the error i recieve. Hopefully it will be enough to demonstrate what I am doing wrong.
    Outline of the Problem
    Create an Array of Users (user) - Working
    Create and Array of Accounts containing Beginning balance and Account Number (accountNum) - Working
    Set Array owner using last name - Working
    Process Transactions - Returning the returning the following error:
    Exception in thread "main" java.lang.NullPointerException
         at account.transaction(account.java:90)
         at accountTest.main(accountTest.java:64)
    If i set memberType to static It worked earlier. I hope this is enough code and description to help identify the problem. I can include more if you need.
    Thank you in advance!
    Lava
    Class Customer
         private String firstName;
         private String lastName ;
         private String memberType;
         public customer(String first, String last, String member)
              firstName = first;
              lastName = last;
              memberType = member;
         public void setMemberType( String m )
               memberType = m;
         public String getMemberType()
              return memberType;
         }Class Account
         private customer owner;
    public void setOwner(customer user)
              owner = user;
         public customer getOwner()
              return owner;
    public void transaction(account[] accountNum)
    if ( owner.getMemberType().equals("Premier" ));

    >
    Based on what I have done the program operates fine if I make member type static. >
    It has to do with how static fields and instance fields are or are not given default values at runtime. Making the customer member static means that for all instances of the Account class, the customer variable will refer to the same object. For different objects of the Account class, will your customer variable refer to the same object? If so, it should be static and thus a class member. If not, it should be an instance member.

  • Pages & AppleScript - adding content and new pages

    I build iOS apps for a living and I am taking a stab at making a developer's guide for each app I create (classes and methods used, some terminology, etc.). I'm able to get a list of all my class files and methods of each class from XCode using AppleScript. What I would like to do now is bring them into a Pages document and add some styling to the text. I can get Pages to make a new document from a template but I can't seem to do anything after that - adding a page or text to the template - the template is one page with some styles and a text box placed on page 1. Here's my code for Pages:
    tell application "Pages"
       make new document with properties {template name:"DeveloperGuide"}
       tell front document
           set bodyText to body text
           return bodyText
       end tell
    end tell
    It's been a while since I've used AppleScript and I've never scripted pages so I'm not sure if this is the right approach. It's nice to see that after two years the notoriously ill documented AppleScript dictionaries still exist. Anyway, my return from the code above is "missing value".
    Any help would be appreciated.

    Are you aware there are two types of templates in Pages? Word processing and pages layout?

  • How to copy an array element in one class to an array in another class?

    Hi,
    I have a ClassRoom class that stores a list of Student objects in an array. How would I copy a Student object from the Student[] array in the ClassRoom class to an array in another class?
    Is it something like this:
    System.arraycopy(Students, 2, AnotherClass.Array, 0, 2);In an array do the items get copied over existing array elements or can the be added to the end? If so, how would I specify add copied object reference to the end of the array in the other class?

    drew22299 wrote:
    Hi,
    I have a ClassRoom class that stores a list of Student objects in an array. How would I copy a Student object from the Student[] array in the ClassRoom class to an array in another class?
    Is it something like this:
    System.arraycopy(Students, 2, AnotherClass.Array, 0, 2);In an array do the items get copied over existing array elements or can the be added to the end? If so, how would I specify add copied object reference to the end of the array in the other class?System.arrayCopy will overwrite whatever is already in the array. It is your job to make sure it copies into the proper array location.
    That being said, you're only moving a single student. This is not something you would use arrayCopy for, as you can just do that with simple assignment. Also, you should consider giving Class a method to add a student to its student list, as the class should know how many students it has and can easily "append" to the array.
    Note: I hope you noticed the quotes around append. Java's arrays are fixed size. Once allocated, their size cannot change. You may want to consider using one of the List implementations (ArrayList, for example) instead.

  • Getting Sum, Count and Distinct Count of a file

    Hi all this is a UNIX question.
    I have a large flat file with millions of records.
    col1|col2|col3
    1|a|b
    2|c|d
    3|e|f
    3|g|h
    footer****
    I am supposed to calculate the sum of col1 =9, count of col1 =4, and distinct count of col1 =c3
    I would like it if you avoid external commands like AWK. Also, can we do the same by creating a function?
    Please bear in mind that the file is huge
    Thanks in advance

    This sounds like homework for a shell class, but here goes. Save into a file, maybe "doit". Run it like this:
    $ ./doit < data
    <snip>
    #!/bin/sh
    got0=0
    got1=0
    got2=0
    got3=0
    got4=0
    got5=0
    got6=0
    got7=0
    got8=0
    got9=0
    sum=0
    cnt=0
    IFS='|'
    while read c1 c2 c3 junk; do
    # Sum and count
    echo "c1=${c1}"
    case "${c1}" in
    [0-9] )
         sum=$(expr ${sum} + ${c1})
         cnt=$(expr ${cnt} + 1)
    esac
    # Distinct
    case "${c1}" in
    0 )     got0=1;;
    1 )     got1=1;;
    2 )     got2=1;;
    3 )     got3=1;;
    4 )     got4=1;;
    5 )     got5=1;;
    6 )     got6=1;;
    7 )     got7=1;;
    8 )     got8=1;;
    9 )     got9=1;;
    esac
    done
    echo "cnt=${cnt}"
    echo "sum=${sum}"
    echo "distinct="$(expr $got0 + $got1 + $got2 + $got3 + $got4 + $got5 + $got6 + $got7 + $got8 + $got9)
    <snip>

  • Can i use array.count in line?

    All,
    I have one small oracle program that take a ',' separated string as an input
    and assigns the individual string to a nested table.
    I am wondering if I can directly use array.count in my sql below
    instead of assigning the count of the array 1st and then
    using it.
    l_cause_codes_array := util_pkg.tokenize_string(p_cause_codes_csv, ',');
    l_count := l_cause_codes_array.count;
    My current sql:
    delete from po_complaint_cause p
    where p.po_number = p_po_number
    and p.comp_code = p_comp_code
    and l_count > 1;
    I would like to do something like:
    delete from po_complaint_cause p
    where p.po_number = p_po_number
    and p.comp_code = p_comp_code
    and l_l_cause_codes_array.count> 1;
    I just want to reduce one context switch if possible.
    Thanks.

    Hi,
    did it give an error? Did you try? But it is possible.
    But why not the next code:
      l_cause_codes_array := util_pkg.tokenize_string(p_cause_codes_csv, ',');
      if l_cause_codes_array.count >1
      then
        delete from po_complaint_cause p
        where p.po_number = p_po_number
        and p.comp_code = p_comp_code
      end if;Do only the delete if it is bigger than 1, that is I think the fastest switch.
    Herald ten Dam
    http://htendam.wordpress.com

  • Getting the "code" of a class as byte array

    Hi!
    My problem is the following. My algorithm gets a Class object and it should return the code of the class as byte array.
    e.g. public byte [] getTheCode (Class forThisClass);
    I found out, that I can get an InputStream for a ressource, so that i can load my own classes like getResourceAsStream("my/package/MyClass.class"), but it should also be possible to get the code of the built-in classes like String, Integer etc.
    thanks, Ingo

    The real name of String is java.lang.String; perhaps you didn't use the full name.No, that's not the problem. The classloader of java.lang.String is usually the bootstrap class loader, and its Class.getClassLoader() == null.
    Class.getClassLoader() explicitly defers to the system class loader (not the bootstrap class loader) if getClassLoader() == null, The system class loader (the thing that looks at CLASSPATH, etc.) cannot load anything from rt.jar.
    So basically I think you're sort of SOL, unless you want to check for this condition yourself. I.e. first try your approach (using getResourceAsStream()), and if that returns null, go and open ${java.home}/lib/rt.jar, and walk it on your own.

  • Public class ArrayEx extends Array

    Hi, I'm very bad at OO programming, but I'm trying to learn.
    I want to add some functions to my Arrays, like checking if
    arrays contain a value (indexOf can be equal to 0, which is false,
    though actually I'm used to the loose data typing of as2, so this
    may not be quite true. Bear with me though, I want to learn how to
    extend a class). So I'm trying to write a class that extends the
    basic Array class.
    I am confused about the constructor, I want to mimic the
    behaviour of the Array class but I'm not sure if I need to write
    functions for each method of Array. Since my ArrayEx extends the
    Array class it should inherit the array functions right? So it
    should already have .pop() and .push() ext. defined? How should I
    write my constructor to store the data the same way as the Array
    class does though?
    Is there somewhere I can look at the internal Array class to
    figure out how it does it?
    What I have written so far appears at the bottom of the
    message. I include questions as comments.
    I hope someone can help me out. I'm sorry if I'm asking stuff
    that seems obvious. Thanks for your time.
    Jon

    I've found the solution to my second set of problems and
    since I chose to trouble you all with the question I thought I'd
    post the answer.
    First problem, I had declared the ArrayEx class as dynamic
    but not as public. Should read;
    dynamic public class ArrayEx extends Array{
    Second problem. An empty constructor function, by default,
    calls the parent constructor function with no arguements. Since I
    wanted to construct my new array class like the default array class
    i had to add some code to handle that.
    So here is the working class;

  • Track public classes, interfaces and methods by ID

    Hi All,
    I'm wondering whether there is a tool to assign a unique ID to classes, interfaces and methods (eg. within Javadoc) and track these IDs.
    The reason I'd need such a feature is that I'd like to do requirements tracking in an easy but complete way. I have a document containing functional specifications (with IDs) and on the other side there is the source code; where the javadoc of the public methods and classes is my software specification. What I now want to do is make a link between the IDs in the functional spec to the IDs in the sofware spec (ie. the source code).
    Does anybody know of such a tool (commercial or not)?
    Thanks,
    Daniel

    I'm a bit confused as to whether or not I understand you correctly. Please tell me if the following pseudocode is somewhat like the solution you are looking for:
    class MethodFunctionality {
       private Class methodClass;
       private String methodSignature;
       private List methodFunctions;
        *   Returns true if the method is used for the specified
        *   requirement, false otherwise.
       public boolean fulfills(int requirementId) {
          if methodFunctions.contains(requirementId)
             return true;
          else
             return false;
       public String getMethodSignature() {
          return this.methodSingature;
       public Class getMethodClass() {
          return this.methodClass;
        *   Returns an array with IDs of each functional
        *   requirement covered by the method.
       public int[] getCoverage() {
          return this.methodFunctions;
    class ClassFunctionality {
       private Map methodDetails;
       private List classFunctions;
       public MethodFunctionality getMethodDetails(String methodSignature) {
          return (MethodFunctionality) this.methodDetails.get(methodSignature);
        *   Returns true if the class is used for the specified
        *   requirement, false otherwise.
       public boolean fulfills(int requirementId) {
          if classFunctions.contains(requirementId)
             return true;
          else
             return false;
        *   Returns an array with IDs of each functional
        *   requirement covered by the class.
       public int[] getCoverage() {
          return this.classFunctions;
    }Mapping classes and methods to functionality like this would both allow you to query each class and method for all the functional requirements they claim to cover and would allow you to collect all classes and methods involved for a particular functional requirement.

  • NXT Flatten to String Not Working with Clusters and Arrays

    Hello,
    My name is Joshua and I am from the FIRST Tech Challenge Team 4318, Green Machine. We are trying to write a program that will write to a configuration file and read it back. The idea is that we will be able to write to a config file from our computer that will be read by our autonomous program when it runs. This will define what the autonomous program does.
    The easiest way to do this seems to be flattening a data structure to a string, saving it to a file, and then reading back and unflattening it. The issue is that the flatten to string and unflatten from string VIs don't seem to work with arrays and clusters on the NXT. It does work when running on the computer. We've tried arrays, clusters, clusters in arrays and arrays in clusters, none seem to work. Thinking it was something to do with reading the string from a file, we tried bypassing the file functionality, still not working. It does work with basic data types though, such as strings and numbers.
    No error is thrown from what we can tell. All you get is a blank data structure out of the unflatten VI.
    The program attached is a test program I've been working on to get this functionality to work. It will display the hex content of what is going into the file, coming out of the file, and then the resulting data from the unflatten string, as well as any errors that have been thrown. The data type we are using simulates what we would like to store. There is also a file length in and out counter. The out file is a little larger because the NXT write file VI adds a new line character on to the end (thus the use of the strip white space VI). This character was corrupting even basic data types saved to file.
    I would like to know if there is a problem with what we are doing, or if it is simply not possible to flatten arrays on the NXT. Please ask if you have any questions about the code. Thank you in advanced!
    Joshua
    Attachments:
    ReadableTest.vi ‏20 KB

    Hi jfireball,
    This is a very interesting situation. Take a look at what kbbersch said. I also urge you to post in the FTC Forums. You posted your question to the general LabVIEW forums, but by posting to the FTC Forums, you will have access to others that are using the NXT hardware.
    David B.
    Applications Engineer
    National Instruments

  • Component Definition and Arrays in 8

    Is there any way to get the component inspector window to
    display the numbers next to items in an array? It's rediculous that
    they won't appear, is it a bug? I'm on a Mac G5 OS 10.4.5.
    Dan P.

    you can assign a variable's default value in the component
    definition dialog box, but you must initialize the variable in your
    class definition and you must define what that variable does in
    your class definition.

Maybe you are looking for

  • Multiple accounts with the same iTunes???

    I'm looking at getting my wife the iPod Nano. I have the iPod 20GB Color Display. If she has the iPod Nano does iTunes allow you to have two separate accounts within the same iTunes so you we have our own sets of music? Or would we have to have two s

  • Adobe Media Encoder CS4 doesn't encode audio

    I'm having trouble getting the Adobe Media Encoder CS4 to work properly. I have tried multiple files of different lengths but end up with the same output. Nice video encoding, but the audio starts and then cuts out after a couple of seconds. The long

  • Cant get 2.1 to work on Audigy 2

    I could only get 2 speaker to work but not 2., and in the speaker setting it only show 2, 4, 5., 6., 7. speaker there is no 2. and if i try to select any of them it just pop back to 2 speaker. Im using Digital Optical out. Can some help me out. Thank

  • Diference between STO and Shipment order?

    Hi All , There are two plants , one is manufacturing and other is sales .  In sales plant sales order is created and after MRP run Purchase requisition is created(for getting materisl from production plant) . In me59 we convert this Preq to shipment

  • Code best practice question LV2013

    I am still fairly new to LabVIEW programming and I have been learning from the online self paced classes. I started in June of 2012. I am currently working on a new program front panel (host) vi and I am trying to determine a better way to implement