Methods Summary |
---|
private java.lang.String | filter$(java.lang.String _range)
String res = "";
for (int i = 0 ; i < _range.length () ; i++){
char ch = _range.charAt (i);
if ( ch != '$" ){
res = res + ch;
}
}
return res;
|
public int | get26Sys(java.lang.String _s)
int sum = 0;
int multiplier = 1;
if (_s != "") {
for (int i = _s.length ()-1 ; i >= 0 ; i--){
char ch = _s.charAt (i);
int val = Character.getNumericValue (ch) - Character.getNumericValue ('A")+1;
sum = sum + val * multiplier;
multiplier = multiplier * 26;
}
return sum;
}
return WRONG_POS;
|
public java.lang.String | getAddress()
String result = "";
if(m_sheetName != null)
result += m_sheetName+"!";
if(m_cellFrom != null){
result += m_cellFrom;
if(m_cellTo != null)
result += ":" + m_cellTo;
}
return result;
|
public java.lang.String | getCharPart(java.lang.String _value)
String result = "";
int digitpos = getFirstDigitPosition (_value);
if(digitpos >= 0){
result = _value.substring (0, digitpos);
}
return result;
|
public java.lang.String | getDigitPart(java.lang.String _value)
String result = "";
int digitpos = getFirstDigitPosition (_value);
if(digitpos >= 0){
result = _value.substring (digitpos);
}
return result;
|
private int | getFirstDigitPosition(java.lang.String _value)
int result = WRONG_POS;
if(_value != null && _value.trim ().length () == 0){
return result;
}
_value = _value.trim ();
int length = _value.length ();
for(int i = 0; i < length; i++){
if(Character.isDigit (_value.charAt (i))){
result = i;
break;
}
}
return result;
|
public java.lang.String | getFromCell()
return m_cellFrom;
|
public int | getHeight()
if(m_cellFrom != null && m_cellTo != null){
int toY = getYPosition (m_cellTo);
int fromY = getYPosition (m_cellFrom);
if ((toY == WRONG_POS) || (fromY == WRONG_POS)){
return 0;
}else
return toY - fromY + 1;
}
return 0;
|
public java.lang.String | getRange()
String result = "";
if(m_cellFrom != null){
result += m_cellFrom;
if(m_cellTo != null)
result += ":" + m_cellTo;
}
return result;
|
public java.lang.String | getSheetName()
return m_sheetName;
|
public java.lang.String | getToCell()
return m_cellTo;
|
public int | getWidth()
if(m_cellFrom != null && m_cellTo != null){
int toX = getXPosition (m_cellTo);
int fromX = getXPosition (m_cellFrom);
if ((toX == WRONG_POS) || (fromX == WRONG_POS)){
return 0;
}else
return toX - fromX + 1;
}
return 0;
|
public int | getXPosition(java.lang.String _subrange)
int result = WRONG_POS;
String tmp = filter$ (_subrange);
tmp = this.getCharPart (_subrange);
// we will process only 2 letters ranges
if (isLetter (tmp) && ((tmp.length () == 2)|| (tmp.length () == 1) )){
result = get26Sys (tmp);
}
return result;
|
public int | getYPosition(java.lang.String _subrange)
int result = WRONG_POS;
_subrange = _subrange.trim ();
if (_subrange.length () != 0){
String digitstr = getDigitPart (_subrange);
try {
result = Integer.parseInt (digitstr);
if (result > MAX_HEIGHT){
result = WRONG_POS;
}
}
catch (Exception ex) {
result = WRONG_POS;
}
}
return result;
|
public boolean | hasCell()
if(m_cellFrom == null)
return false;
return true;
|
public boolean | hasRange()
return (m_cellFrom != null && m_cellTo != null && !m_cellFrom.equals(m_cellTo));
|
public boolean | hasSheetName()
if(m_sheetName == null)
return false;
return true;
|
private void | init(java.lang.String _url)
_url = removeString(_url, "$");
_url = removeString(_url, "'");
String[] urls = parseURL (_url);
m_sheetName = urls[0];
m_cellFrom = urls[1];
m_cellTo = urls[2];
//What if range is one celled ?
if (m_cellTo == null){
m_cellTo = m_cellFrom;
}
//Removing noneeds characters
m_cellTo = removeString(m_cellTo,".");
|
private static boolean | intern_isSheetNameOk(java.lang.String _sheetName, boolean _canBeWaitSpace)
for (int i = 0 ; i < _sheetName.length (); i++){
char ch = _sheetName.charAt (i);
if (! (Character.isLetterOrDigit (ch) || (ch == '_")||
_canBeWaitSpace&&(ch == ' "))){
return false;
}
}
return true;
|
public boolean | isCellOk(java.lang.String _cell)
if (_cell != null){
if ( (getYPosition (_cell) != WRONG_POS) &&
(getXPosition (_cell) != WRONG_POS) )
return true;
else
return false;
} else
return false;
|
private static boolean | isLetter(java.lang.String _str)
boolean res = true;
if ( !_str.equals ("") ){
for (int i = 0 ; i < _str.length (); i++){
char ch = _str.charAt (i);
if (! Character.isLetter (ch)){
res = false;
break;
}
}
}else
res = false;
return res;
|
public boolean | isSheetNameOk()
return isSheetNameOk (m_sheetName);
|
public static boolean | isSheetNameOk(java.lang.String _sheetName)
boolean res = false;
if ( ( _sheetName != null) && !_sheetName.equals ("")){
res = intern_isSheetNameOk (_sheetName,true);
}else
res = true;
return res;
|
public java.lang.String | numTo26Sys(int _num)
int sum = 0;
int reminder;
String s ="";
do{
_num --;
reminder = _num % 26;
int val = 65 + reminder;
_num = _num / 26;
s = (char)val + s; // reverce
}while(_num > 0);
return s;
|
private java.lang.String[] | parseURL(java.lang.String _url)
String[] result = new String[3];
int index = _url.indexOf(':");
if (index >= 0) {
String fromStr = _url.substring(0, index);
String toStr = _url.substring(index+1);
index = fromStr.indexOf('!");
if (index >= 0) {
result[0] = fromStr.substring(0, index);
result[1] = fromStr.substring(index+1);
} else {
result[1] = fromStr;
}
index = toStr.indexOf('!");
if (index >= 0) {
result[2] = toStr.substring(index+1);
} else {
result[2] = toStr;
}
} else {
index = _url.indexOf('!");
if (index >= 0) {
result[0] = _url.substring(0, index);
result[1] = _url.substring(index+1);
} else {
result[1] = _url;
}
}
return result;
|
public java.lang.String | removeString(java.lang.String _source, java.lang.String _match)
return replaceString(_source, _match, "");
|
public java.lang.String | replaceString(java.lang.String _source, java.lang.String _oldPattern, java.lang.String _newPattern)
StringBuffer res = new StringBuffer(_source);
int pos = -1;
while ((pos = res.toString().indexOf(_oldPattern, pos)) > -1){
res.replace(pos, pos + _oldPattern.length(), _newPattern);
}
return res.toString();
|
public void | setSize(int _width, int _height)
if(m_cellFrom == null)
m_cellFrom = "a1";
int tlX, tlY, rbX, rbY;
tlX = getXPosition (m_cellFrom);
tlY = getYPosition (m_cellFrom);
m_cellTo = numTo26Sys (tlX + _width - 1);
m_cellTo += String.valueOf (tlY + _height - 1);
|