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


Java VersionString类代码示例

本文整理汇总了Java中jnlp.sample.util.VersionString的典型用法代码示例。如果您正苦于以下问题:Java VersionString类的具体用法?Java VersionString怎么用?Java VersionString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: findMatch

import jnlp.sample.util.VersionString; //导入依赖的package包/类
/** This method finds the best match, or return the best error code. The
    *  result parameter must be an array with room for one element.
    *
    *  If a match is found, the method returns DownloadResponse.STS_00_OK
    *  If one or more entries matches on: name, version-id, os, arch, and locale,
    *  then the one with the highest version-id is set in the result[0] field.
    *
    *  If a match is not found, it returns an error code, either: ERR_10_NO_RESOURCE,
    *  ERR_11_NO_VERSION, ERR_20_UNSUP_OS, ERR_21_UNSUP_ARCH, ERR_22_UNSUP_LOCALE,
    *  ERR_23_UNSUP_JRE.
    *
    */
   public int findMatch(List list, String name, DownloadRequest dreq, JnlpResource[] result) {
if (list == null) return DownloadResponse.ERR_10_NO_RESOURCE;
// Setup return values
VersionID bestVersionId = null;
int error = DownloadResponse.ERR_10_NO_RESOURCE;
VersionString vs = new VersionString(dreq.getVersion());
// Iterate through entries
for(int i = 0; i < list.size(); i++) {
    JnlpResource respath = (JnlpResource)list.get(i);
    VersionID vid = new VersionID(respath.getVersionId());	
    int sts = matchEntry(name, vs, dreq, respath, vid);
    if (sts == DownloadResponse.STS_00_OK) {
	if (result[0] == null || vid.isGreaterThan(bestVersionId)) {
	    result[0] = respath;
	    bestVersionId = vid;
	}
    } else {
	error = Math.max(error, sts);
    }
}
return (result[0] != null) ? DownloadResponse.STS_00_OK : error;
   }
 
开发者ID:steveonjava,项目名称:widgetfx,代码行数:35,代码来源:ResourceCatalog.java

示例2: matchEntry

import jnlp.sample.util.VersionString; //导入依赖的package包/类
public int matchEntry(String name, VersionString vs, DownloadRequest dreq, JnlpResource jnlpres, VersionID vid) {
if (!name.equals(jnlpres.getName())) {
    return DownloadResponse.ERR_10_NO_RESOURCE;
}
if (!vs.contains(vid)) {
    return DownloadResponse.ERR_11_NO_VERSION;
}
if (!prefixMatchLists(jnlpres.getOSList(), dreq.getOS())) {
    return DownloadResponse.ERR_20_UNSUP_OS;
}
if (!prefixMatchLists(jnlpres.getArchList(), dreq.getArch())) {
    return DownloadResponse.ERR_21_UNSUP_ARCH;
}
if (!prefixMatchLists(jnlpres.getLocaleList(), dreq.getLocale())) {
    return DownloadResponse.ERR_22_UNSUP_LOCALE;
}
return DownloadResponse.STS_00_OK;
   }
 
开发者ID:steveonjava,项目名称:widgetfx,代码行数:19,代码来源:ResourceCatalog.java

示例3: matchEntry

import jnlp.sample.util.VersionString; //导入依赖的package包/类
public int matchEntry( String name, VersionString vs, DownloadRequest dreq, JnlpResource jnlpres, VersionID vid )
{
    if ( !name.equals( jnlpres.getName() ) )
    {
        return DownloadResponse.ERR_10_NO_RESOURCE;
    }
    if ( !vs.contains( vid ) )
    {
        return DownloadResponse.ERR_11_NO_VERSION;
    }
    if ( !prefixMatchLists( jnlpres.getOSList(), dreq.getOS() ) )
    {
        return DownloadResponse.ERR_20_UNSUP_OS;
    }
    if ( !prefixMatchLists( jnlpres.getArchList(), dreq.getArch() ) )
    {
        return DownloadResponse.ERR_21_UNSUP_ARCH;
    }
    if ( !prefixMatchLists( jnlpres.getLocaleList(), dreq.getLocale() ) )
    {
        return DownloadResponse.ERR_22_UNSUP_LOCALE;
    }
    return DownloadResponse.STS_00_OK;
}
 
开发者ID:mojohaus,项目名称:webstart,代码行数:25,代码来源:ResourceCatalog.java

示例4: findMatch

import jnlp.sample.util.VersionString; //导入依赖的package包/类
/** This method finds the best match, or return the best error code. The
 *  result parameter must be an array with room for one element.
 *
 *  If a match is found, the method returns DownloadResponse.STS_00_OK
 *  If one or more entries matches on: name, version-id, os, arch, and locale,
 *  then the one with the highest version-id is set in the result[0] field.
 *
 *  If a match is not found, it returns an error code, either: ERR_10_NO_RESOURCE,
 *  ERR_11_NO_VERSION, ERR_20_UNSUP_OS, ERR_21_UNSUP_ARCH, ERR_22_UNSUP_LOCALE,
 *  ERR_23_UNSUP_JRE.
 *
 */
public int findMatch(List list, String name, DownloadRequest dreq, JnlpResource[] result) {
    if (list == null) return DownloadResponse.ERR_10_NO_RESOURCE;
    // Setup return values
    VersionID bestVersionId = null;
    int error = DownloadResponse.ERR_10_NO_RESOURCE;
    VersionString vs = new VersionString(dreq.getVersion());
    // Iterate through entries
    for(int i = 0; i < list.size(); i++) {
        JnlpResource respath = (JnlpResource)list.get(i);
        VersionID vid = new VersionID(respath.getVersionId());
        int sts = matchEntry(name, vs, dreq, respath, vid);
        if (sts == DownloadResponse.STS_00_OK) {
            if (result[0] == null || vid.isGreaterThan(bestVersionId)) {
                result[0] = respath;
                bestVersionId = vid;
            }
        } else {
            error = Math.max(error, sts);
        }
    }
    return (result[0] != null) ? DownloadResponse.STS_00_OK : error;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:35,代码来源:ResourceCatalog.java

示例5: matchEntry

import jnlp.sample.util.VersionString; //导入依赖的package包/类
public int matchEntry(String name, VersionString vs, DownloadRequest dreq, JnlpResource jnlpres, VersionID vid) {
    if (!name.equals(jnlpres.getName())) {
        return DownloadResponse.ERR_10_NO_RESOURCE;
    }
    if (!vs.contains(vid)) {
        return DownloadResponse.ERR_11_NO_VERSION;
    }
    if (!prefixMatchLists(jnlpres.getOSList(), dreq.getOS())) {
        return DownloadResponse.ERR_20_UNSUP_OS;
    }
    if (!prefixMatchLists(jnlpres.getArchList(), dreq.getArch())) {
        return DownloadResponse.ERR_21_UNSUP_ARCH;
    }
    if (!prefixMatchLists(jnlpres.getLocaleList(), dreq.getLocale())) {
        return DownloadResponse.ERR_22_UNSUP_LOCALE;
    }
    return DownloadResponse.STS_00_OK;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:19,代码来源:ResourceCatalog.java

示例6: findMatch

import jnlp.sample.util.VersionString; //导入依赖的package包/类
/**
 * This method finds the best match, or return the best error code. The
 * result parameter must be an array with room for one element.
 * <p>
 * If a match is found, the method returns DownloadResponse.STS_00_OK
 * If one or more entries matches on: name, version-id, os, arch, and locale,
 * then the one with the highest version-id is set in the result[0] field.
 * <p>
 * If a match is not found, it returns an error code, either: ERR_10_NO_RESOURCE,
 * ERR_11_NO_VERSION, ERR_20_UNSUP_OS, ERR_21_UNSUP_ARCH, ERR_22_UNSUP_LOCALE,
 * ERR_23_UNSUP_JRE.
 *
 * @param list   TODO
 * @param name   TODO
 * @param dreq   TODO
 * @param result TODO
 * @return TODO
 */
public int findMatch( List list, String name, DownloadRequest dreq, JnlpResource[] result )
{
    if ( list == null )
    {
        return DownloadResponse.ERR_10_NO_RESOURCE;
    }
    // Setup return values
    VersionID bestVersionId = null;
    int error = DownloadResponse.ERR_10_NO_RESOURCE;
    VersionString vs = new VersionString( dreq.getVersion() );
    // Iterate through entries
    for ( Object aList : list )
    {
        JnlpResource respath = (JnlpResource) aList;
        VersionID vid = new VersionID( respath.getVersionId() );
        int sts = matchEntry( name, vs, dreq, respath, vid );
        if ( sts == DownloadResponse.STS_00_OK )
        {
            if ( result[0] == null || vid.isGreaterThan( bestVersionId ) )
            {
                result[0] = respath;
                bestVersionId = vid;
            }
        }
        else
        {
            error = Math.max( error, sts );
        }
    }
    return ( result[0] != null ) ? DownloadResponse.STS_00_OK : error;
}
 
开发者ID:mojohaus,项目名称:webstart,代码行数:50,代码来源:ResourceCatalog.java

示例7: isJavawsVersion

import jnlp.sample.util.VersionString; //导入依赖的package包/类
public static boolean isJavawsVersion(DownloadRequest dreq, String version) {
String javawsAgent = "javaws";
String jwsVer = dreq.getHttpRequest().getHeader("User-Agent");


// check the request is coming from javaws
if (!jwsVer.startsWith("javaws-")) {
    // this is the new style User-Agent string
    // User-Agent: JNLP/1.0.1 javaws/1.4.2 (b28) J2SE/1.4.2
    StringTokenizer st = new StringTokenizer(jwsVer);
    while (st.hasMoreTokens()) {
	String verString = st.nextToken();
	int index = verString.indexOf(javawsAgent);
	if (index != -1) {
	    verString = verString.substring(index + javawsAgent.length() + 1);
	    return VersionString.contains(version, verString);
	}
    }
    return false;
}

// extract the version id from the download request
int startIndex = jwsVer.indexOf("-");

if (startIndex == -1) {
    return false;
}

int endIndex = jwsVer.indexOf("/");

if (endIndex == -1 || endIndex < startIndex) {
    return false;
}

String verId = jwsVer.substring(startIndex + 1, endIndex);


// check whether the versionString contains the versionId
return VersionString.contains(version, verId);

   }
 
开发者ID:steveonjava,项目名称:widgetfx,代码行数:42,代码来源:JarDiffHandler.java

示例8: isJavawsVersion

import jnlp.sample.util.VersionString; //导入依赖的package包/类
public static boolean isJavawsVersion( DownloadRequest dreq, String version )
{
    String javawsAgent = "javaws";
    String jwsVer = dreq.getHttpRequest().getHeader( "User-Agent" );

    // check the request is coming from javaws
    if ( !jwsVer.startsWith( "javaws-" ) )
    {
        // this is the new style User-Agent string
        // User-Agent: JNLP/1.0.1 javaws/1.4.2 (b28) J2SE/1.4.2
        StringTokenizer st = new StringTokenizer( jwsVer );
        while ( st.hasMoreTokens() )
        {
            String verString = st.nextToken();
            int index = verString.indexOf( javawsAgent );
            if ( index != -1 )
            {
                verString = verString.substring( index + javawsAgent.length() + 1 );
                return VersionString.contains( version, verString );
            }
        }
        return false;
    }

    // extract the version id from the download request
    int startIndex = jwsVer.indexOf( "-" );

    if ( startIndex == -1 )
    {
        return false;
    }

    int endIndex = jwsVer.indexOf( "/" );

    if ( endIndex == -1 || endIndex < startIndex )
    {
        return false;
    }

    String verId = jwsVer.substring( startIndex + 1, endIndex );

    // check whether the versionString contains the versionId
    return VersionString.contains( version, verId );

}
 
开发者ID:mojohaus,项目名称:webstart,代码行数:46,代码来源:JarDiffHandler.java

示例9: isJavawsVersion

import jnlp.sample.util.VersionString; //导入依赖的package包/类
public static boolean isJavawsVersion(DownloadRequest dreq, String version) {
    String javawsAgent = "javaws";
    String jwsVer = dreq.getHttpRequest().getHeader("User-Agent");


    // check the request is coming from javaws
    if (!jwsVer.startsWith("javaws-")) {
        // this is the new style User-Agent string
        // User-Agent: JNLP/1.0.1 javaws/1.4.2 (b28) J2SE/1.4.2
        StringTokenizer st = new StringTokenizer(jwsVer);
        while (st.hasMoreTokens()) {
            String verString = st.nextToken();
            int index = verString.indexOf(javawsAgent);
            if (index != -1) {
                verString = verString.substring(index + javawsAgent.length() + 1);
                return VersionString.contains(version, verString);
            }
        }
        return false;
    }

    // extract the version id from the download request
    int startIndex = jwsVer.indexOf("-");

    if (startIndex == -1) {
        return false;
    }

    int endIndex = jwsVer.indexOf("/");

    if (endIndex == -1 || endIndex < startIndex) {
        return false;
    }

    String verId = jwsVer.substring(startIndex + 1, endIndex);


    // check whether the versionString contains the versionId
    return VersionString.contains(version, verId);

}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:42,代码来源:JarDiffHandler.java


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