~vcs-imports/evaristo/trunk

« back to all changes in this revision

Viewing changes to com/m16e/mpbiz/MpBizCompanyData.java

  • Committer: m16e
  • Date: 2004-01-21 17:10:58 UTC
  • Revision ID: vcs-imports@canonical.com-20040121171058-00w8f93ynnk2xwve
Initial revision

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Log: MpBizCompanyData.java,v $
 
3
 * Revision 1.1  2004/01/21 17:11:31  m16e
 
4
 * Initial revision
 
5
 *
 
6
 * Revision 1.2  2003/07/24 16:49:30  carlos
 
7
 * *** empty log message ***
 
8
 *
 
9
 * Revision 1.1.1.1  2003/07/23 00:33:50  carlos
 
10
 * Reload v1r2
 
11
 *
 
12
 * Revision 1.1.1.1  2003/07/22 14:04:37  carlos
 
13
 * CVS reload: v1r2
 
14
 *
 
15
 * Revision 1.1.1.1  2003/07/17 14:56:39  carlos
 
16
 * v1r2
 
17
 *
 
18
 * Revision 1.1.1.1  2003/07/15 17:03:30  carlos
 
19
 * Start of v1r2
 
20
 *
 
21
 * Revision 1.1.1.1  2003/06/19 02:23:17  carlos
 
22
 * restarting point - v1r01
 
23
 *
 
24
 * Revision 1.1.1.1  2003/03/31 11:25:29  carlos
 
25
 * Starting point (v. 1.1-pre1)
 
26
 *
 
27
 *
 
28
 */
 
29
 
 
30
package com.m16e.mpbiz;
 
31
 
 
32
import java.io.*;
 
33
import java.util.*;
 
34
import java.sql.*;
 
35
 
 
36
import javax.swing.*;
 
37
 
 
38
import com.m16e.free.tools.files.*;
 
39
import com.m16e.free.tools.xml.*;
 
40
 
 
41
////////////////////////////////////////////////////////////
 
42
public class MpBizCompanyData
 
43
{
 
44
        public static final String FILE_NAME = "company-data.xml";
 
45
        
 
46
        public static final String TAG_CAPITAL = "capital";
 
47
        public static final String TAG_COMPANY_DATA = "company-data";
 
48
        public static final String TAG_COMPANY_SHORT_NAME = "company-short-name";
 
49
        public static final String TAG_COMPANY_LONG_NAME = "company-long-name";
 
50
        public static final String TAG_COMPANY_ADDRESS_1 = "company-address-1";
 
51
        public static final String TAG_COMPANY_ADDRESS_2 = "company-address-2";
 
52
        public static final String TAG_FINANTIAL_ID = "finantial-id";
 
53
        public static final String TAG_REGISTO= "registo";
 
54
        public static final String TAG_TELEPHONES = "telephones";
 
55
        public static final String TAG_TELEPHONE = "telephone";
 
56
        public static final String TAG_URL = "url";
 
57
        public static final String TAG_EMAIL = "e-mail";
 
58
        public static final String TAG_LOGO = "logo";
 
59
 
 
60
        public static final String ATTR_NAME = "name";
 
61
        
 
62
        String shortCompanyName = null;
 
63
        String longCompanyName = null;
 
64
        String companyAddress1 = null;
 
65
        String companyAddress2 = null;
 
66
        String finantialId = null;
 
67
        String capitalSocial = null;
 
68
        String registo = null;
 
69
        
 
70
        Object[][] telephones = null;
 
71
        String url = null;
 
72
        String email = null;
 
73
        ImageIcon logo = null;
 
74
        
 
75
        ////////////////////////////////////////////////////////////
 
76
        public MpBizCompanyData()
 
77
                throws IOException
 
78
        {
 
79
                String companyFile = FileUtils.readFile( FILE_NAME );
 
80
                String elCompanyData =
 
81
                        XmlInterpreter.getElement( companyFile, TAG_COMPANY_DATA );
 
82
                String companyData =
 
83
                        XmlInterpreter.getElementValue( elCompanyData, TAG_COMPANY_DATA );
 
84
                
 
85
                shortCompanyName = 
 
86
                        XmlInterpreter.getElementValue( companyData, TAG_COMPANY_SHORT_NAME );
 
87
                longCompanyName = 
 
88
                        XmlInterpreter.getElementValue( companyData, TAG_COMPANY_LONG_NAME );
 
89
                companyAddress1 =
 
90
                        XmlInterpreter.getElementValue( companyData, TAG_COMPANY_ADDRESS_1 );
 
91
                companyAddress2 =
 
92
                        XmlInterpreter.getElementValue( companyData, TAG_COMPANY_ADDRESS_2 );
 
93
                finantialId = 
 
94
                        XmlInterpreter.getElementValue( companyData, TAG_FINANTIAL_ID );
 
95
                capitalSocial = 
 
96
                        XmlInterpreter.getElementValue( companyData, TAG_CAPITAL );
 
97
                registo = 
 
98
                        XmlInterpreter.getElementValue( companyData, TAG_REGISTO );
 
99
                String elTelephones =
 
100
                        XmlInterpreter.getElement( companyData, TAG_TELEPHONES );
 
101
                String[] aux =
 
102
                        XmlInterpreter.getElementArray( elTelephones, TAG_TELEPHONE );
 
103
                if( aux != null )
 
104
                {
 
105
                        telephones = new Object[ aux.length ] [ 2 ];
 
106
                        for ( int f = 0; f < aux.length; f++ )
 
107
                        {
 
108
                                telephones[f][0] =
 
109
                                        XmlInterpreter.getAttributeValue( aux[f], ATTR_NAME );
 
110
                                telephones[f][1] =
 
111
                                        XmlInterpreter.getElementValue( aux[f], TAG_TELEPHONE );
 
112
                        }
 
113
                }
 
114
                else
 
115
                        telephones = new Object[0][];
 
116
                url = 
 
117
                        XmlInterpreter.getElementValue( companyData, TAG_URL );
 
118
                email = 
 
119
                 XmlInterpreter.getElementValue( companyData, TAG_EMAIL );
 
120
                String aux2 = 
 
121
                 XmlInterpreter.getElementValue( companyData, TAG_LOGO );
 
122
                if ( aux2.length() > 0 )
 
123
                        logo = new ImageIcon( aux2 );
 
124
        }
 
125
 
 
126
        ////////////////////////////////////////////////////////////
 
127
        public String getShortCompanyName() { return shortCompanyName; }
 
128
        public String getLongCompanyName() { return longCompanyName; }
 
129
        public String getCompanyAddress1() { return companyAddress1; }
 
130
        public String getCompanyAddress2() { return companyAddress2; }
 
131
        public String getFinantialId() { return finantialId; }
 
132
        public String getCapitalSocial() { return capitalSocial; }
 
133
        public String getRegisto() { return registo; }
 
134
        public Object[][] getTelephones() { return telephones; }
 
135
        
 
136
        ////////////////////////////////////////////////////////////
 
137
        public String getTelAndFax() 
 
138
        { 
 
139
                return "Tel: " + telephones[0][1] + " - Fax: " + telephones[1][1];
 
140
        }
 
141
        
 
142
        ////////////////////////////////////////////////////////////
 
143
        public String getUrl() { return url; }
 
144
        public String getEmail() { return email; }
 
145
        public ImageIcon getLogo() { return logo; }
 
146
        
 
147
        ////////////////////////////////////////////////////////////
 
148
        
 
149
}