Java Code Examples for com.apple.jobjc.foundation.NSString

The following examples show how to use com.apple.jobjc.foundation.NSString. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: dragonwell8_jdk   Source File: CategoryTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testAppKit_NSString(){
    AppKitFramework APPKIT = JObjC.getInstance().AppKit();

    NSString nstr = Utils.get().strings().nsString("mirzapirza");
    NSStringCategory nstrx = APPKIT.NSStringCategory(nstr);
    NSSize sz = nstrx.sizeWithAttributes(null);

    assertEquals(57.0, sz.width());
    assertEquals(15.0, sz.height());
}
 
Example 2
Source Project: dragonwell8_jdk   Source File: IBDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void mainWithoutAppMain(String[] args){
    Toolkit.getDefaultToolkit();

    Utils.get().threads().performOnMainThread(new Runnable(){
        public void run() {
            APPKIT.NSApplication().sharedApplication();
            NSApplication APP = APPKIT.NSApp();

            NSString nibName = Utils.get().strings().nsString("MainMenu");
            boolean loadedNib = APPKIT.NSBundleCategory().loadNibNamed_owner(nibName, APP);
            if(!loadedNib) throw new RuntimeException("Failed to load nib.");
        }}, false);
}
 
Example 3
Source Project: hottub   Source File: VarArgsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSDictionary(){
    NSString v1 = Utils.get().strings().nsString("value1");
    NSString v2 = Utils.get().strings().nsString("value2");
    NSString k1 = Utils.get().strings().nsString("key1");
    NSString k2 = Utils.get().strings().nsString("key2");

    NSDictionary dict = ((NSDictionary)FND.NSDictionary().alloc()).initWithObjectsAndKeys(v1, k1, v2, k2, null);

    NSString nsdescr = dict.description();
    String jdescr = Utils.get().strings().javaString(nsdescr);

    assertEquals("{\n    key1 = value1;\n    key2 = value2;\n}", jdescr);
}
 
Example 4
Source Project: hottub   Source File: VarArgsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSString_initWithFormat(){
    String expected = "1 + 0.2 = 1.2 abracadabra";
    NSString format = Utils.get().strings().nsString("%d + %.1f = %.1f %@");

    NSString abra = Utils.get().strings().nsString("abracadabra");

    NSString nstr = ((NSString)FND.NSString().alloc()).initWithFormat(format, 1, 0.2, 1.2, abra);
    String actual = Utils.get().strings().javaString(nstr);

    assertEquals(expected, actual);
}
 
Example 5
Source Project: dragonwell8_jdk   Source File: VarArgsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSDictionary(){
    NSString v1 = Utils.get().strings().nsString("value1");
    NSString v2 = Utils.get().strings().nsString("value2");
    NSString k1 = Utils.get().strings().nsString("key1");
    NSString k2 = Utils.get().strings().nsString("key2");

    NSDictionary dict = ((NSDictionary)FND.NSDictionary().alloc()).initWithObjectsAndKeys(v1, k1, v2, k2, null);

    NSString nsdescr = dict.description();
    String jdescr = Utils.get().strings().javaString(nsdescr);

    assertEquals("{\n    key1 = value1;\n    key2 = value2;\n}", jdescr);
}
 
Example 6
Source Project: hottub   Source File: NSClassTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSClassName(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSString cname = s.className();
    String jcname = Utils.get().strings().javaString(cname);
    assertEquals("NSCFString", jcname);
}
 
Example 7
Source Project: jdk8u_jdk   Source File: IBDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void mainWithoutAppMain(String[] args){
    Toolkit.getDefaultToolkit();

    Utils.get().threads().performOnMainThread(new Runnable(){
        public void run() {
            APPKIT.NSApplication().sharedApplication();
            NSApplication APP = APPKIT.NSApp();

            NSString nibName = Utils.get().strings().nsString("MainMenu");
            boolean loadedNib = APPKIT.NSBundleCategory().loadNibNamed_owner(nibName, APP);
            if(!loadedNib) throw new RuntimeException("Failed to load nib.");
        }}, false);
}
 
Example 8
Source Project: dragonwell8_jdk   Source File: NSClassTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSClassName(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSString cname = s.className();
    String jcname = Utils.get().strings().javaString(cname);
    assertEquals("NSCFString", jcname);
}
 
Example 9
Source Project: jdk8u-dev-jdk   Source File: IBDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void mainWithoutAppMain(String[] args){
    Toolkit.getDefaultToolkit();

    Utils.get().threads().performOnMainThread(new Runnable(){
        public void run() {
            APPKIT.NSApplication().sharedApplication();
            NSApplication APP = APPKIT.NSApp();

            NSString nibName = Utils.get().strings().nsString("MainMenu");
            boolean loadedNib = APPKIT.NSBundleCategory().loadNibNamed_owner(nibName, APP);
            if(!loadedNib) throw new RuntimeException("Failed to load nib.");
        }}, false);
}
 
Example 10
Source Project: jdk8u-jdk   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSStringNSStringMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final NSString orig = Utils.get().strings().nsString("foobar");
    final String expected = "foobarfoobarfoobar";

    final MsgSend sel = new MsgSend(runtime, "stringTimesThree:", IDCoder.INST, IDCoder.INST);
    sel.init(ctx, instObj);
    IDCoder.INST.push(ctx, orig);
    sel.invoke(ctx);
    NSString ret = (NSString) IDCoder.INST.pop(ctx);
    assertEquals(expected, Utils.get().strings().javaString(ret));
}
 
Example 11
Source Project: jdk8u_jdk   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public NSString stringTimesThree(NSString nss){
    int count = 3;
    String jss = Utils.get().strings().javaString(nss);
    String js2 = "";
    while(count-- > 0)
        js2 += jss;
    return Utils.get().strings().nsString(js2);
}
 
Example 12
Source Project: TencentKona-8   Source File: IBDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void mainWithoutAppMain(String[] args){
    Toolkit.getDefaultToolkit();

    Utils.get().threads().performOnMainThread(new Runnable(){
        public void run() {
            APPKIT.NSApplication().sharedApplication();
            NSApplication APP = APPKIT.NSApp();

            NSString nibName = Utils.get().strings().nsString("MainMenu");
            boolean loadedNib = APPKIT.NSBundleCategory().loadNibNamed_owner(nibName, APP);
            if(!loadedNib) throw new RuntimeException("Failed to load nib.");
        }}, false);
}
 
Example 13
Source Project: openjdk-8   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSStringNSStringMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final NSString orig = Utils.get().strings().nsString("foobar");
    final String expected = "foobarfoobarfoobar";

    final MsgSend sel = new MsgSend(runtime, "stringTimesThree:", IDCoder.INST, IDCoder.INST);
    sel.init(ctx, instObj);
    IDCoder.INST.push(ctx, orig);
    sel.invoke(ctx);
    NSString ret = (NSString) IDCoder.INST.pop(ctx);
    assertEquals(expected, Utils.get().strings().javaString(ret));
}
 
Example 14
Source Project: TencentKona-8   Source File: VarArgsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSString_initWithFormat(){
    String expected = "1 + 0.2 = 1.2 abracadabra";
    NSString format = Utils.get().strings().nsString("%d + %.1f = %.1f %@");

    NSString abra = Utils.get().strings().nsString("abracadabra");

    NSString nstr = ((NSString)FND.NSString().alloc()).initWithFormat(format, 1, 0.2, 1.2, abra);
    String actual = Utils.get().strings().javaString(nstr);

    assertEquals(expected, actual);
}
 
Example 15
Source Project: TencentKona-8   Source File: VarArgsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSDictionary(){
    NSString v1 = Utils.get().strings().nsString("value1");
    NSString v2 = Utils.get().strings().nsString("value2");
    NSString k1 = Utils.get().strings().nsString("key1");
    NSString k2 = Utils.get().strings().nsString("key2");

    NSDictionary dict = ((NSDictionary)FND.NSDictionary().alloc()).initWithObjectsAndKeys(v1, k1, v2, k2, null);

    NSString nsdescr = dict.description();
    String jdescr = Utils.get().strings().javaString(nsdescr);

    assertEquals("{\n    key1 = value1;\n    key2 = value2;\n}", jdescr);
}
 
Example 16
public void testNSStringNSStringMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final NSString orig = Utils.get().strings().nsString("foobar");
    final String expected = "foobarfoobarfoobar";

    final MsgSend sel = new MsgSend(runtime, "stringTimesThree:", IDCoder.INST, IDCoder.INST);
    sel.init(ctx, instObj);
    IDCoder.INST.push(ctx, orig);
    sel.invoke(ctx);
    NSString ret = (NSString) IDCoder.INST.pop(ctx);
    assertEquals(expected, Utils.get().strings().javaString(ret));
}
 
Example 17
public NSString stringTimesThree(NSString nss){
    int count = 3;
    String jss = Utils.get().strings().javaString(nss);
    String js2 = "";
    while(count-- > 0)
        js2 += jss;
    return Utils.get().strings().nsString(js2);
}
 
Example 18
Source Project: hottub   Source File: NSClassTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
Example 19
Source Project: TencentKona-8   Source File: NSClassTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSClassName(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSString cname = s.className();
    String jcname = Utils.get().strings().javaString(cname);
    assertEquals("NSCFString", jcname);
}
 
Example 20
Source Project: jdk8u_jdk   Source File: VarArgsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSString_initWithFormat(){
    String expected = "1 + 0.2 = 1.2 abracadabra";
    NSString format = Utils.get().strings().nsString("%d + %.1f = %.1f %@");

    NSString abra = Utils.get().strings().nsString("abracadabra");

    NSString nstr = ((NSString)FND.NSString().alloc()).initWithFormat(format, 1, 0.2, 1.2, abra);
    String actual = Utils.get().strings().javaString(nstr);

    assertEquals(expected, actual);
}
 
Example 21
Source Project: jdk8u60   Source File: CategoryTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testAppKit_NSString(){
    AppKitFramework APPKIT = JObjC.getInstance().AppKit();

    NSString nstr = Utils.get().strings().nsString("mirzapirza");
    NSStringCategory nstrx = APPKIT.NSStringCategory(nstr);
    NSSize sz = nstrx.sizeWithAttributes(null);

    assertEquals(57.0, sz.width());
    assertEquals(15.0, sz.height());
}
 
Example 22
Source Project: jdk8u-jdk   Source File: NSClassTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
Example 23
Source Project: jdk8u-jdk   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public NSString stringTimesThree(NSString nss){
    int count = 3;
    String jss = Utils.get().strings().javaString(nss);
    String js2 = "";
    while(count-- > 0)
        js2 += jss;
    return Utils.get().strings().nsString(js2);
}
 
Example 24
Source Project: jdk8u60   Source File: VarArgsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSString_initWithFormat(){
    String expected = "1 + 0.2 = 1.2 abracadabra";
    NSString format = Utils.get().strings().nsString("%d + %.1f = %.1f %@");

    NSString abra = Utils.get().strings().nsString("abracadabra");

    NSString nstr = ((NSString)FND.NSString().alloc()).initWithFormat(format, 1, 0.2, 1.2, abra);
    String actual = Utils.get().strings().javaString(nstr);

    assertEquals(expected, actual);
}
 
Example 25
Source Project: jdk8u60   Source File: VarArgsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSDictionary(){
    NSString v1 = Utils.get().strings().nsString("value1");
    NSString v2 = Utils.get().strings().nsString("value2");
    NSString k1 = Utils.get().strings().nsString("key1");
    NSString k2 = Utils.get().strings().nsString("key2");

    NSDictionary dict = ((NSDictionary)FND.NSDictionary().alloc()).initWithObjectsAndKeys(v1, k1, v2, k2, null);

    NSString nsdescr = dict.description();
    String jdescr = Utils.get().strings().javaString(nsdescr);

    assertEquals("{\n    key1 = value1;\n    key2 = value2;\n}", jdescr);
}
 
Example 26
Source Project: jdk8u60   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSStringNSStringMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final NSString orig = Utils.get().strings().nsString("foobar");
    final String expected = "foobarfoobarfoobar";

    final MsgSend sel = new MsgSend(runtime, "stringTimesThree:", IDCoder.INST, IDCoder.INST);
    sel.init(ctx, instObj);
    IDCoder.INST.push(ctx, orig);
    sel.invoke(ctx);
    NSString ret = (NSString) IDCoder.INST.pop(ctx);
    assertEquals(expected, Utils.get().strings().javaString(ret));
}
 
Example 27
Source Project: jdk8u60   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public NSString stringTimesThree(NSString nss){
    int count = 3;
    String jss = Utils.get().strings().javaString(nss);
    String js2 = "";
    while(count-- > 0)
        js2 += jss;
    return Utils.get().strings().nsString(js2);
}
 
Example 28
Source Project: jdk8u-dev-jdk   Source File: VarArgsTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSString_initWithFormat(){
    String expected = "1 + 0.2 = 1.2 abracadabra";
    NSString format = Utils.get().strings().nsString("%d + %.1f = %.1f %@");

    NSString abra = Utils.get().strings().nsString("abracadabra");

    NSString nstr = ((NSString)FND.NSString().alloc()).initWithFormat(format, 1, 0.2, 1.2, abra);
    String actual = Utils.get().strings().javaString(nstr);

    assertEquals(expected, actual);
}
 
Example 29
Source Project: jdk8u60   Source File: NSClassTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testNSClassPop(){
    NSString s = ((NSString) FND.NSString().alloc()).init();

    NSStringClass c = s.classNSClass();
    String jdescr = Utils.get().strings().javaString(c.description());
    assertEquals("NSCFString", jdescr);
}
 
Example 30
Source Project: openjdk-8-source   Source File: IBDemo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void mainWithoutAppMain(String[] args){
    Toolkit.getDefaultToolkit();

    Utils.get().threads().performOnMainThread(new Runnable(){
        public void run() {
            APPKIT.NSApplication().sharedApplication();
            NSApplication APP = APPKIT.NSApp();

            NSString nibName = Utils.get().strings().nsString("MainMenu");
            boolean loadedNib = APPKIT.NSBundleCategory().loadNibNamed_owner(nibName, APP);
            if(!loadedNib) throw new RuntimeException("Failed to load nib.");
        }}, false);
}