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

📄 modulespec.java

📁 jpeg2000编解码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * Gets default value of the specified component. If no specification have     * been entered for this component, returns default value.     *     * @param c Component index      *     * @return The default value for this component (Must be casted before     * use)     *     * @see #setCompDef     * */    public Object getCompDef(int c) {        if ( specType == SPEC_TYPE_TILE ) {            throw new Error("Illegal use of ModuleSpec class");        }	if(compDef==null || compDef[c]==null) {	    return getDefault();	} else {	    return compDef[c];        }    }    /**      * Sets default value for specified tile and specValType tag if allowed by     * its priority.     *     * @param c Tile index.     * */    public void setTileDef(int t, Object value) {        if ( specType == SPEC_TYPE_COMP ) {            String errMsg = "Option whose value is '"+value+"' cannot be "                + "specified for tiles as it is a 'component only' specific "                + "option";            throw new Error(errMsg);        }	if(tileDef==null) {	    tileDef = new Object[nTiles];        }	for(int i=0; i<nComp; i++) {	    if(specValType[t][i]<SPEC_TILE_DEF) {		specValType[t][i] = SPEC_TILE_DEF;	    }	}	tileDef[t] = value;    }    /**      * Gets default value of the specified tile. If no specification has been     * entered, it returns the default value.     *     * @param t Tile index      *     * @return The default value for this tile (Must be casted before use)     *     * @see #setTileDef     * */    public Object getTileDef(int t) {        if ( specType == SPEC_TYPE_COMP ) {            throw new Error("Illegal use of ModuleSpec class");        }	if(tileDef==null || tileDef[t]==null) {	    return getDefault();	} else {	    return tileDef[t];        }    }    /**      * Sets value for specified tile-component.     *     * @param t Tie index      *      * @param c Component index      * */    public void setTileCompVal(int t,int c, Object value) {        if ( specType != SPEC_TYPE_TILE_COMP ) {            String errMsg = "Option whose value is '"+value+"' cannot be "                + "specified for ";            switch (specType) {            case SPEC_TYPE_TILE:                errMsg += "components as it is a 'tile only' specific option";                break;            case SPEC_TYPE_COMP:                errMsg += "tiles as it is a 'component only' specific option";                break;            }            throw new Error(errMsg);        }	if(tileCompVal==null)	    tileCompVal = new Hashtable();	specValType[t][c] = SPEC_TILE_COMP; 	tileCompVal.put("t"+t+"c"+c,value);    }    /**      * Gets value of specified tile-component. This method calls getSpec but     * has a public access.     *     * @param t Tile index      *     * @param c Component index      *     * @return The value of this tile-component (Must be casted before use)     *     * @see #setTileCompVal     *     * @see #getSpec      * */    public Object getTileCompVal(int t,int c) {        if ( specType != SPEC_TYPE_TILE_COMP ) {            throw new Error("Illegal use of ModuleSpec class");        }	return getSpec(t,c);	    }    /**      * Gets value of specified tile-component without knowing if a specific     * tile-component value has been previously entered. It first check if a     * tile-component specific value has been entered, then if a tile specific     * value exist, then if a component specific value exist. If not the     * default value is returned.     *     * @param t Tile index     *     * @param c Component index     *     * @return Value for this tile component.     * */    protected Object getSpec(int t,int c) {	switch(specValType[t][c]) {	case SPEC_DEF:	    return getDefault();	case SPEC_COMP_DEF:	    return getCompDef(c);	case SPEC_TILE_DEF:	    return getTileDef(t);	case SPEC_TILE_COMP:	    return tileCompVal.get("t"+t+"c"+c);	default:	    throw new IllegalArgumentException("Not recognized spec type");	}    }    /**      * Return the spec type of the given tile-component.     *     * @param t Tile index     *     * @param c Component index     * */    public byte getSpecValType(int t,int c) {	return specValType[t][c];    }    /**      * Whether or not specifications have been entered for the given     * component.     *     * @param c Index of the component     *     * @return True if component specification has been defined     * */    public boolean isCompSpecified(int c){	if(compDef==null || compDef[c]==null) {	    return false;	} else {	    return true;        }    }    /**      * Whether or not specifications have been entered for the given tile.     *     * @param t Index of the tile     *     * @return True if tile specification has been entered     * */    public boolean isTileSpecified(int t) {	if(tileDef==null || tileDef[t]==null) {	    return false;	} else {	    return true;        }    }    /**      * Whether or not a tile-component specification has been defined     *     * @param t Tile index     *     * @param c Component index     *     * @return True if a tile-component specification has been defined.     * */    public boolean isTileCompSpecified(int t,int c) {	if(tileCompVal==null || tileCompVal.get("t"+t+"c"+c)==null) {	    return false;	} else {	    return true;        }    }    /**      * This method is responsible of parsing tile indexes set and component     * indexes set for an option. Such an argument must follow the following     * policy:<br>     *      * <tt>t&lt;indexes set&gt;</tt> or <tt>c&lt;indexes set&gt;</tt> where     * tile or component indexes are separated by commas or a dashes.     *     * <p><u>Example:</u><br>     * <li> <tt>t0,3,4</tt> means tiles with indexes 0, 3 and 4.<br>     * <li> <tt>t2-4</tt> means tiles with indexes 2,3 and 4.<br>     *     * It returns a boolean array skteching which tile or component are     * concerned by the next parameters.     *     * @param word The word to parse.     *     * @param maxIdx Maximum authorized index     *     * @return Indexes concerned by this parameter.     * */    public static final boolean[] parseIdx(String word, int maxIdx) {	int nChar = word.length(); // Number of characters	char c = word.charAt(0);   // current character	int idx = -1;              // Current (tile or component) index	int lastIdx = -1;          // Last (tile or component) index	boolean isDash = false;    // Whether or not last separator was a dash	boolean[] idxSet = new boolean[maxIdx];	int i=1; // index of the current character	while(i<nChar) {	    c = word.charAt(i);	    if(Character.isDigit(c)) {		if(idx==-1) {		    idx = 0;                }		idx = idx*10+ (c-'0');	    } else {		if(idx==-1 || (c!=',' && c!='-')) {		   throw new IllegalArgumentException("Bad construction for "+						      "parameter: "+word); 		}		if(idx<0 || idx>=maxIdx) {		    throw new IllegalArgumentException("Out of range index "+                                                       "in "+						       "parameter `"+word+                                                       "' : "+idx); 		}		// Found a comma		if(c==',') {		    if(isDash) { // Previously found a dash, fill idxSet			for(int j=lastIdx+1; j<idx; j++){			    idxSet[j] = true;			}		    }		    isDash = false;		} else {// Found a dash		    isDash = true;                }		// Udate idxSet		idxSet[idx] = true;		lastIdx = idx;		idx=-1;	    }	    i++;	}	// Process last found index	if(idx<0 || idx>=maxIdx) {	    throw new IllegalArgumentException("Out of range index in "+					       "parameter `"+word+"' : "+idx);	}	if(isDash) {	    for(int j=lastIdx+1; j<idx; j++) {		idxSet[j] = true;	    }        }	idxSet[idx] = true;	return idxSet;    }}

⌨️ 快捷键说明

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