⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 version.java

📁 openacs source for CPE wan management
💻 JAVA
字号:
/*
 * Version.java
 *
 * Created on 衑餿adienis, 2007, Lapkri鑙o 24, 13.04
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.openacs.utils;

import java.util.logging.Level;

/*
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
*/
import java.util.logging.Logger;
/**
 *
 * @author Administrator
 */
public class Version {
    
    /** Creates a new instance of Version */
    public Version(String sv) {
        Set (sv);
    }
    void Set (String sv) {
        if (sv == null || sv.equals("")) {
            v = new int [1];
            v [0] = 0;
            return;
        }
        String sva [] = sv.split("\\.");
        v = new int [sva.length];
        boolean fEntireValid = true;
        for (int i = 0; i < sva.length; i++) {
            try {
                v [i] = Integer.parseInt(sva [i]);
            } catch (NumberFormatException ex) {
                fEntireValid = false;
            }
        }
        if (!fEntireValid) {
             Logger.getLogger(getClass().getName()).log(Level.WARNING, "Invalid version string: "+sv+" Non numeric elements assumed to be 0");
        }
        
    }
    public boolean isUptodate (Version ver2) {
        int v2[] = ver2.v;
        int c = (v2.length < v.length) ? v2.length : v.length;
        for (int i = 0; i < c; i++) {
            if (v2[i] < v[i]) return false;
            if (v2[i] > v[i]) return true;
        }
        if (v2.length < v.length) return false;
        return true;
    }
    /*
    static public void validate (FacesContext context, UIComponent toValidate, Object value) {
        if (!Pattern.matches("^[0-9]+(\\.[0-9]+)*", (String)value)) {
            ((UIInput)toValidate).setValid(false);
            context.addMessage(toValidate.getClientId(context), new FacesMessage("Version format must be digits[.digits]"));
        }
    }
    */
    private int [] v;

    @Override
    public String toString() {
        String s = "";
        for (int i = 0; i < v.length; i++) {
            if (!s.equals("")) s += ".";
            s += v[i];
        }
        
        return s;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -