Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/debugtools/DDR_VM/src/com/ibm/j9ddr/libraries/Footer.java
6005 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2018 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
package com.ibm.j9ddr.libraries;
24
25
import java.io.File;
26
import java.io.Serializable;
27
import java.util.ArrayList;
28
29
//enclosing class for the footer
30
31
public class Footer implements Serializable {
32
private static final long serialVersionUID = -8257413568391677575L;
33
private final int version = 1;
34
private final FooterLibraryEntry[] entries;
35
private int index = 0;
36
private ArrayList<String> errorMessages = new ArrayList<String>();
37
38
public Footer(int size) {
39
entries = new FooterLibraryEntry[size];
40
}
41
42
public int getVersion() {
43
return version;
44
}
45
46
public void addErrorMessage(String message) {
47
errorMessages.add(message);
48
}
49
50
public String[] getErrorMessages() {
51
String[] messages = new String[errorMessages.size()];
52
return errorMessages.toArray(messages);
53
}
54
55
public void addEntry(String path, int size, long start) {
56
int pos = path.lastIndexOf(File.separatorChar);
57
String name = (pos == -1) ? path : path.substring(pos + 1);
58
FooterLibraryEntry entry = new FooterLibraryEntry(path, name, size, start);
59
entries[index++] = entry;
60
}
61
62
@Override
63
public String toString() {
64
StringBuilder data = new StringBuilder();
65
data.append("Footer : version ");
66
data.append(version);
67
data.append("\n");
68
for(int i = 0; i < entries.length; i++) {
69
if(entries[i] != null) { //skip over entries that have not been initialized
70
data.append(entries[i].toString());
71
}
72
}
73
return data.toString();
74
}
75
76
public FooterLibraryEntry findEntry(String path) {
77
FooterLibraryEntry namematch = null; //match against the name
78
for(int i = 0; i < entries.length; i++) {
79
if(entries[i] != null) { //skip over entries that have not been initialized
80
if(entries[i].getPath().equals(path)) {
81
return entries[i];
82
}
83
if(entries[i].getName().equals(path)) {
84
namematch = entries[i];
85
}
86
}
87
}
88
return namematch; //return null or a name match if one was found
89
}
90
91
public FooterLibraryEntry[] getEntries() {
92
return entries;
93
}
94
95
}
96
97