com.apple.jobjc.foundation.NSString Java Examples

The following examples show how to use com.apple.jobjc.foundation.NSString. 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 File: CategoryTest.java    From jdk8u-jdk with 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 File: NSClassTest.java    From openjdk-jdk8u-backup with 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 #3
Source File: VarArgsTest.java    From openjdk-jdk8u-backup with 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 #4
Source File: CategoryTest.java    From jdk8u-dev-jdk with 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 #5
Source File: IBDemo.java    From openjdk-jdk8u-backup with 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 #6
Source File: VarArgsTest.java    From openjdk-jdk8u-backup with 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 #7
Source File: NSClassTest.java    From openjdk-8-source with 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 #8
Source File: IBDemo.java    From jdk8u-jdk with 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 #9
Source File: VarArgsTest.java    From jdk8u-jdk with 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 #10
Source File: IBDemo.java    From jdk8u-jdk with 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 #11
Source File: SubclassingTest.java    From jdk8u-jdk with 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 File: NSClassTest.java    From jdk8u-dev-jdk with 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 #13
Source File: CategoryTest.java    From hottub with 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 #14
Source File: CategoryTest.java    From jdk8u-jdk with 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 #15
Source File: CategoryTest.java    From openjdk-jdk8u-backup with 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 #16
Source File: SubclassingTest.java    From openjdk-8-source with 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 #17
Source File: SubclassingTest.java    From hottub with 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 #18
Source File: NSClassTest.java    From openjdk-jdk8u with 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 File: NSClassTest.java    From jdk8u_jdk with 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 #20
Source File: SubclassingTest.java    From openjdk-jdk8u with 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 #21
Source File: SubclassingTest.java    From hottub with 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 #22
Source File: SubclassingTest.java    From openjdk-8-source with 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 #23
Source File: VarArgsTest.java    From openjdk-jdk8u with 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 #24
Source File: CategoryTest.java    From openjdk-8 with 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 #25
Source File: IBDemo.java    From openjdk-jdk8u with 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 #26
Source File: IBDemo.java    From openjdk-8-source with 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 #27
Source File: NSClassTest.java    From jdk8u60 with 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 #28
Source File: VarArgsTest.java    From jdk8u-dev-jdk with 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 File: SubclassingTest.java    From jdk8u60 with 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 #30
Source File: SubclassingTest.java    From jdk8u60 with 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));
}