1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*
* Created on May 6, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
Copyright 2003 Joseph Barnett
This File is part of "one 2 oh my god"
"one 2 oh my god" is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Free Software Foundation; either version 2 of the License, or
your option) any later version.
"one 2 oh my god" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with "one 2 oh my god"; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package itunes.client.request;
import itunes.*;
import itunes.client.*;
import java.util.ArrayList;
/**
* @author jbarnett
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class DatabasesRequest extends Request {
protected ArrayList mlclDataFields;
protected ArrayList mlitDataFields;
public DatabasesRequest(String server, int port, int sessionId) throws NoServerPermissionException{
super(server, port, "databases?session-id="+sessionId);
}
public DatabasesRequest(String server, int port, String rs) throws NoServerPermissionException{
super(server, port, rs);
}
protected void Process() throws NoServerPermissionException {
super.Process();
parseMLCL();
}
protected void parseMLCL() {
for (int i = 0; i < mlclIndexes.size(); i++) {
byte[] mlclData = ((FieldPair)fieldPairs.get(((Integer)mlclIndexes.get(i)).intValue())).value;
mlclDataFields = this.processDataFields(mlclData,0);
}
parseMLIT();
}
protected void parseMLIT() {
mlitDataFields = new ArrayList();
for (int i = 0; i < mlitIndexes.size(); i++) {
byte[] mlitData = ((FieldPair)mlclDataFields.get(((Integer)mlitIndexes.get(i)).intValue())).value;
mlitDataFields.add(processDataFields(mlitData,0));
}
}
public int getLibraryCount() {
return mlclDataFields.size();
}
public int getDbId(int i) {
ArrayList currMlitDataFields = ((ArrayList)mlitDataFields.get(i));
int index = currMlitDataFields.indexOf(new FieldPair("miid",null,0,0));
FieldPair fp = (FieldPair)currMlitDataFields.get(index);
return Request.readInt(fp.value,0);
}
public int getSongCount(int i) {
ArrayList currMlitDataFields = ((ArrayList)mlitDataFields.get(i));
int index = currMlitDataFields.indexOf(new FieldPair("mimc",null,0,0));
FieldPair fp = (FieldPair)currMlitDataFields.get(index);
return Request.readInt(fp.value,0);
}
public ArrayList getDbs() {
ArrayList dbs = new ArrayList();
for (int i = 0; i < mlitDataFields.size();i++) {
ArrayList fps = ((ArrayList)mlitDataFields.get(i));
String name=null;
int id=0;
Database d = new Database();
for (int j = 0; j < fps.size();j++) {
FieldPair fp =((FieldPair)fps.get(j));
if (fp.name.equals("miid")) {
d.id = Request.readInt(fp.value,0);
} else if (fp.name.equals("minm")) {
d.name = Request.readString(fp.value,0,fp.value.length);
}
}
dbs.add(d);
}
return dbs;
}
public String toString() {
String ret = super.toString();
for (int i = 0; i < mlclDataFields.size();i++) {
ret += ((FieldPair)mlclDataFields.get(i)).toString() + "\n";
}
for (int i=0; i < mlitDataFields.size();i++) {
ArrayList fps = ((ArrayList)mlitDataFields.get(i));
for (int j = 0; j < fps.size();j++) {
ret += ((FieldPair)fps.get(j)).toString() + "\n";
}
}
return ret;
}
}
|