Path: blob/master/debugtools/DDR_VM/src/com/ibm/j9ddr/libraries/Footer.java
6005 views
/*******************************************************************************1* Copyright (c) 1991, 2018 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122package com.ibm.j9ddr.libraries;2324import java.io.File;25import java.io.Serializable;26import java.util.ArrayList;2728//enclosing class for the footer2930public class Footer implements Serializable {31private static final long serialVersionUID = -8257413568391677575L;32private final int version = 1;33private final FooterLibraryEntry[] entries;34private int index = 0;35private ArrayList<String> errorMessages = new ArrayList<String>();3637public Footer(int size) {38entries = new FooterLibraryEntry[size];39}4041public int getVersion() {42return version;43}4445public void addErrorMessage(String message) {46errorMessages.add(message);47}4849public String[] getErrorMessages() {50String[] messages = new String[errorMessages.size()];51return errorMessages.toArray(messages);52}5354public void addEntry(String path, int size, long start) {55int pos = path.lastIndexOf(File.separatorChar);56String name = (pos == -1) ? path : path.substring(pos + 1);57FooterLibraryEntry entry = new FooterLibraryEntry(path, name, size, start);58entries[index++] = entry;59}6061@Override62public String toString() {63StringBuilder data = new StringBuilder();64data.append("Footer : version ");65data.append(version);66data.append("\n");67for(int i = 0; i < entries.length; i++) {68if(entries[i] != null) { //skip over entries that have not been initialized69data.append(entries[i].toString());70}71}72return data.toString();73}7475public FooterLibraryEntry findEntry(String path) {76FooterLibraryEntry namematch = null; //match against the name77for(int i = 0; i < entries.length; i++) {78if(entries[i] != null) { //skip over entries that have not been initialized79if(entries[i].getPath().equals(path)) {80return entries[i];81}82if(entries[i].getName().equals(path)) {83namematch = entries[i];84}85}86}87return namematch; //return null or a name match if one was found88}8990public FooterLibraryEntry[] getEntries() {91return entries;92}9394}959697