1 5 6 package com.raptus.owxv3.api; 7 8 import com.raptus.owxv3.LoggingManager; 9 10 32 public class GResPicture extends GResFile 33 { 34 37 protected int picWidth = 0; 38 39 42 protected int picHeight = 0; 43 44 47 public int getPictureWidth() { return picWidth; } 48 public void setPictureWidth(int width) { this.picWidth = width; } 49 50 public int getPictureHeight() { return picHeight; } 51 public void setPictureHeight(int height) { this.picHeight = height; } 52 53 57 public void setInfo(String infos) 58 { 59 this.fileInfo = infos; 60 61 try 62 { 63 setPictureWidth(getParameterInt("width", infos)); 64 setPictureHeight(getParameterInt("height", infos)); 65 } 66 catch(NumberFormatException e) { 67 LoggingManager.log("Failed to retrieve picture width/height from database!", this); 68 } 69 } 70 71 74 protected int getParameterInt(String param, String str) 75 throws NumberFormatException 76 { 77 if(str == null) 78 return 0; 79 80 int nstart = str.indexOf(param + "=\""); 81 if(nstart == -1) 82 return 0; 83 84 nstart += param.length() + 2; int nend = str.indexOf("\"", nstart); 86 if(nend == -1) 87 return 0; 88 89 String value = str.substring(nstart, nend); 90 if(value == null) 91 return 0; 92 93 return Integer.parseInt(value); 94 } 95 96 } 97 98 99 | Popular Tags |