KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > api > GResPicture


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.api;
7
8 import com.raptus.owxv3.LoggingManager;
9
10 /**
11  *
12  * <hr>
13  * <table width="100%" border="0">
14  * <tr>
15  * <td width="24%"><b>Filename</b></td><td width="76%">GResPicture.java</td>
16  * </tr>
17  * <tr>
18  * <td width="24%"><b>Author</b></td><td width="76%">Guy Zürcher (gzuercher@raptus.com)</td>
19  * </tr>
20  * <tr>
21  * <td width="24%"><b>Date</b></td><td width="76%">24th of April 2001</td>
22  * </tr>
23  * </table>
24  * <hr>
25  * <table width="100%" border="0">
26  * <tr>
27  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
28  * </tr>
29  * </table>
30  * <hr>
31  */

32 public class GResPicture extends GResFile
33 {
34     /**
35      *
36      */

37     protected int picWidth = 0;
38
39     /**
40      *
41      */

42     protected int picHeight = 0;
43
44     /**
45      * Accessor methods
46      */

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     /**
54      * parses automatically the info-field which has the format of width/height
55      * specification in the <img> html-tag. e.g. ... width="100" height="200"
56      */

57     public void setInfo(String JavaDoc infos)
58     {
59         this.fileInfo = infos;
60
61         try
62         {
63             setPictureWidth(getParameterInt("width", infos));
64             setPictureHeight(getParameterInt("height", infos));
65         }
66         catch(NumberFormatException JavaDoc e) {
67             LoggingManager.log("Failed to retrieve picture width/height from database!", this);
68         }
69     }
70
71     /**
72      *
73      */

74     protected int getParameterInt(String JavaDoc param, String JavaDoc str)
75                   throws NumberFormatException JavaDoc
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; // for ="
85
int nend = str.indexOf("\"", nstart);
86         if(nend == -1)
87             return 0;
88
89         String JavaDoc value = str.substring(nstart, nend);
90         if(value == null)
91             return 0;
92
93         return Integer.parseInt(value);
94     }
95
96 }
97
98 /* end class GResPicture */
99
Popular Tags