当前位置: 首页>>代码示例>>Java>>正文


Java Util.split方法代码示例

本文整理汇总了Java中com.codename1.io.Util.split方法的典型用法代码示例。如果您正苦于以下问题:Java Util.split方法的具体用法?Java Util.split怎么用?Java Util.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.codename1.io.Util的用法示例。


在下文中一共展示了Util.split方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: packHeader

import com.codename1.io.Util; //导入方法依赖的package包/类
private int packHeader(byte[] bytes, int offset) {
	try {
		BufferTools.stringIntoByteBuffer(TAG, 0, TAG.length(), bytes, offset);
	} catch (UnsupportedEncodingException e) {
	}
	String s[] = Util.split(version, ".");
	if (s.length > 0) {
		byte majorVersion = Byte.parseByte(s[0]);
		bytes[offset + MAJOR_VERSION_OFFSET] = majorVersion;
	}
	if (s.length > 1) {
		byte minorVersion = Byte.parseByte(s[1]);
		bytes[offset + MINOR_VERSION_OFFSET] = minorVersion;
	}
	packFlags(bytes, offset);
	BufferTools.packSynchsafeInteger(getDataLength(), bytes, offset + DATA_LENGTH_OFFSET);
	return offset + HEADER_LENGTH;
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:19,代码来源:AbstractID3v2Tag.java

示例2: packFooter

import com.codename1.io.Util; //导入方法依赖的package包/类
private int packFooter(byte[] bytes, int offset) {
	try {
		BufferTools.stringIntoByteBuffer(FOOTER_TAG, 0, FOOTER_TAG.length(), bytes, offset);
	} catch (UnsupportedEncodingException e) {
	}
	String s[] = Util.split(version, ".");
	if (s.length > 0) {
		byte majorVersion = Byte.parseByte(s[0]);
		bytes[offset + MAJOR_VERSION_OFFSET] = majorVersion;
	}
	if (s.length > 1) {
		byte minorVersion = Byte.parseByte(s[1]);
		bytes[offset + MINOR_VERSION_OFFSET] = minorVersion;
	}
	packFlags(bytes, offset);
	BufferTools.packSynchsafeInteger(getDataLength(), bytes, offset + DATA_LENGTH_OFFSET);
	return offset + FOOTER_LENGTH;
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:19,代码来源:AbstractID3v2Tag.java

示例3: getSSLCertificates

import com.codename1.io.Util; //导入方法依赖的package包/类
private String[] getSSLCertificates(String url) {
    if (sslCertificates == null) {
        try {
            com.codename1.io.URL uUrl = new com.codename1.io.URL(url);
            String key = uUrl.getHost()+":"+uUrl.getPort();
            String certs = nativeInstance.getSSLCertificates(peer);
            if (certs == null) {
                if (sslCertificatesCache.containsKey(key)) {
                    sslCertificates = sslCertificatesCache.get(key);
                }
                if (sslCertificates == null) {
                    return new String[0];
                }
                return sslCertificates;
            }
            sslCertificates = Util.split(certs, ",");
            sslCertificatesCache.put(key, sslCertificates);
            return sslCertificates;
        } catch (Exception ex) {
            ex.printStackTrace();
            return new String[0];
        }
    }
    return sslCertificates;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:26,代码来源:IOSImplementation.java

示例4: parseString

import com.codename1.io.Util; //导入方法依赖的package包/类
static Map<String,String> parseString(Map<String,String> out, String str) {
    String[] rules = Util.split(str, ";");
    for (String rule : rules) {
        rule = rule.trim();
        if (rule.length() == 0) {
            continue;
        }
        int pos = rule.indexOf(":");
        if (pos == -1) {
            continue;
        }
        String key = rule.substring(0, pos);
        if ("font".equals(key) && out.containsKey("font")) {
            // We may need to merge font rules
            FontInfo newFinfo = StyleParser.parseFont(new FontInfo(), rule.substring(pos+1));
            FontInfo origFinfo = StyleParser.parseFont(new FontInfo(), out.get("font"));
            Float newSize = newFinfo.getSize();
            if (newSize != null && newFinfo.getSizeUnit() != StyleParser.UNIT_INHERIT) {
                origFinfo.setSize(newSize);
                origFinfo.setSizeUnit(newFinfo.getSizeUnit());
            }
            if (newFinfo.getName() != null) {
                origFinfo.setName(newFinfo.getName());
            }
            if (newFinfo.getFile() != null) {
                origFinfo.setFile(newFinfo.getFile());
            }
            out.put(key, origFinfo.toString());
        } else {
            out.put(key, rule.substring(pos+1));
        }

    }
    return out;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:36,代码来源:StyleParser.java

示例5: getSpliceInsets

import com.codename1.io.Util; //导入方法依赖的package包/类
/**
 * For a splicedImage border, this gets the spliced insets as a 4-element array of double values.
 * @param out An out parameter.  4-element array of insets.  Indices {@link Component#TOP}, {@link Component#BOTTOM}, {@link Component#LEFT}, and {@link Component#RIGHT}.
 * @return 4-element array of insets.  Indices {@link Component#TOP}, {@link Component#BOTTOM}, {@link Component#LEFT}, and {@link Component#RIGHT}.
 */
public double[] getSpliceInsets(double[] out) {
    String[] parts = Util.split(BorderInfo.this.getSpliceInsets(), " ");
    
    out[Component.TOP] = Double.parseDouble(parts[0]);
    out[Component.RIGHT] = Double.parseDouble(parts[1]);
    out[Component.BOTTOM] = Double.parseDouble(parts[2]);
    out[Component.LEFT] = Double.parseDouble(parts[3]);
    return out;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:15,代码来源:StyleParser.java

示例6: getClient

import com.codename1.io.Util; //导入方法依赖的package包/类
private GoogleApiClient getClient(SuccessCallback<GoogleApiClient> onConnected) {
    if (mGoogleApiClient == null) {
        Context ctx = AndroidNativeUtil.getContext();
        if (mGoogleApiClient == null) {
            GoogleSignInOptions gso;

            if (clientId != null && clientSecret != null) {
                System.out.println("Generating GoogleSignIn for clientID="+clientId);
                List<Scope> includeScopes = new ArrayList<Scope>();
                Scope firstScope = new Scope(Scopes.PROFILE);
                if (scope != null) {
                    for (String str : Util.split(scope, " ")) {
                        if ("profile".equals(str)) {
                            //str = Scopes.PROFILE;
                            continue;
                        } else if ("email".equals(str)) {
                            str = Scopes.EMAIL;
                        } else if (Scopes.PROFILE.equals(str)) {
                            continue;
                        }
                        if (str.trim().isEmpty()) {
                            continue;
                        }
                        includeScopes.add(new Scope(str.trim()));
                    }
                }
                gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                        //.requestIdToken("555462747934-iujpd5saj4pjpibo7c6r9tbjfef22rh1.apps.googleusercontent.com")
                        .requestIdToken(clientId)
                        .requestScopes(firstScope, includeScopes.toArray(new Scope[includeScopes.size()]))
                        //.requestScopes(Plus.SCOPE_PLUS_PROFILE)
                        //.requestServerAuthCode("555462747934-iujpd5saj4pjpibo7c6r9tbjfef22rh1.apps.googleusercontent.com")
                        .requestServerAuthCode(clientId)
                        .build();
            } else {
                System.out.println("Generating GoogleSignIn without ID token");
                gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).build();
            }
            mGoogleApiClient = new GoogleApiClient.Builder(ctx)
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this)
                    .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                    .build();
        }
    }
    if (mGoogleApiClient.isConnected()) {
        if (onConnected != null) {
            onConnected.onSucess(mGoogleApiClient);
        }
    } else {
        synchronized(onConnectedCallbacks) {
            if (onConnected != null) {
                onConnectedCallbacks.add(onConnected);
            }
            if (!mGoogleApiClient.isConnecting()) {
                mGoogleApiClient.connect(GoogleApiClient.SIGN_IN_MODE_OPTIONAL);
            }
        }
    }
    return mGoogleApiClient;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:62,代码来源:GoogleImpl.java

示例7: dispatchCallback

import com.codename1.io.Util; //导入方法依赖的package包/类
/**
 * Calls the appropriate callback method given a URL that was received 
 * from the NavigationCallback.  It is set up to accept URLs of the 
 * form cn1command:object.method?type1=value1&type2=value2&...&typen=valuen
 * 
 * <p>This method parses the URL and converts all arguments (including the 
 * object and method) into their associated Java representations, then 
 * generates a JavascriptEvent to fire on the scriptMessageReceived
 * browser event.</p>
 * 
 * <p>This method will usually be called on the native platform's GUI
 * thread, but it dispatches the resulting JavascriptEvent on the EDT
 * using Display.callSerially()</p>
 * @param request The URL representing the command that is being called.
 */
private void dispatchCallback(final String request){
    Runnable r = new Runnable(){
        public void run(){
            String command = request.substring(request.indexOf("/!cn1command/")+"/!cn1command/".length());
            // Get the callback id
            String objMethod = command.substring(0, command.indexOf("?"));
            command = command.substring(command.indexOf("?")+1);

            final String self = objMethod.substring(0, objMethod.indexOf("."));
            String method = objMethod.substring(objMethod.indexOf(".")+1);

            // Now let's get the parameters
            String[] keyValuePairs = Util.split(command, "&");
            //Vector params = new Vector();

            int len = keyValuePairs.length;
            Object[] params = new Object[len];
            for ( int i=0; i<len; i++){
                String[] parts = Util.split(keyValuePairs[i], "=");
                if ( parts.length < 2 ){
                    continue;
                }
                String ptype = Util.decode(parts[0], null, true);
                String pval = Util.decode(parts[1], null, true);
                if ( "object".equals(ptype) || "function".equals(ptype) ){
                    params[i] = new JSObject(JavascriptContext.this, pval);
                } else if ( "number".equals(ptype) ){
                    params[i] = Double.valueOf(pval);
                } else if ( "string".equals(ptype)){
                    params[i] = pval;
                } else if ( "boolean".equals(ptype)){
                    params[i] = "true".equals(pval)?Boolean.TRUE:Boolean.FALSE;
                } else {
                    params[i] = null;
                }
            }
            JSObject selfObj = new JSObject(JavascriptContext.this, self);

            JavascriptEvent evt = new JavascriptEvent(selfObj, method, params);
            browser.fireWebEvent("scriptMessageReceived", evt);
        }
    };
    
    Display.getInstance().callSerially(r);
    
    
    
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:64,代码来源:JavascriptContext.java

示例8: parseFont

import com.codename1.io.Util; //导入方法依赖的package包/类
static FontInfo parseFont(FontInfo out, String font) {
    if (font == null || font.trim().length() == 0) {
        return null;
    }
    font = font.trim();
    String[] args = Util.split(font, " ");
    int len = args.length;
    if (len == 1) {
        String arg = args[0].trim();
        if (arg.length() == 0) {
            out.setSize(null);
            out.setSizeUnit(UNIT_INHERIT);
            out.setFile(null);
            out.setName(null);
            return out;
        }
        if (isFontSizeArg(arg)) {
            // This is a size
            parseFontSize(out, arg);
            out.setName(null);
            out.setFile(null);
            return out;
            
        } else {
            out.setSizeUnit(UNIT_INHERIT);
            out.setSize(null);
            parseFontName(out, arg);
            parseFontFile(out, arg);
            
        }
    } else if (len == 2) {
        if (isFontSizeArg(args[0])) {
            parseFontSize(out, args[0]);
            parseFontName(out, args[1]);
            parseFontFile(out, args[1]);
            return out;
        } else {
            out.setSize(null);
            out.setSizeUnit(UNIT_INHERIT);
            parseFontName(out, args[0]);
            parseFontFile(out, args[1]);
            return out;
            
        }

    } else if (len == 3) {
        parseFontSize(out, args[0]);
        parseFontName(out, args[1]);
        parseFontFile(out, args[2]);
        return out;
    } else {
        throw new IllegalArgumentException("Failed to parse font");
    }
    return out;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:56,代码来源:StyleParser.java


注:本文中的com.codename1.io.Util.split方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。