blob: 835fba51c8ba77c976890ee4eb42f14cf05a071b [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 2010, 2011 Nokia and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Nokia - Initial API and implementation
* Broadcom - addition of getPhysicalAddress() to API
*******************************************************************************/
package org.eclipse.cdt.debug.edc.internal.symbols;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.edc.symbols.AbstractAddressInterval;
public class Section extends AbstractAddressInterval implements ISection {
private final int id;
private final long size;
/** the address generated by the linker*/
private final IAddress linkAddress;
private final IAddress physicalAddress;
private final Map<String, Object> properties;
/**
* use {@link Section#Section(int, long, IAddress, IAddress, Map)} if possible;
* this version of the constructor sets a null physicalAddress
* @param id
* @param size
* @param linkAddress
* @param properties
*/
public Section(int id, long size, IAddress linkAddress, Map<String, Object> properties) {
this(id, size, linkAddress, null, properties);
}
/**
* @param id
* @param size
* @param linkAddress
* @param physicalAddress
* @param properties
*/
public Section(int id, long size, IAddress linkAddress, IAddress physicalAddress, Map<String, Object> properties) {
this.id = id;
this.size = size;
this.linkAddress = linkAddress;
this.physicalAddress = physicalAddress;
this.properties = new HashMap<String, Object>(properties); // make a copy
}
public int getId() {
return id;
}
public long getSize() {
return size;
}
public IAddress getLinkAddress() {
return linkAddress;
}
public IAddress getPhysicalAddress() {
return physicalAddress;
}
public Map<String, Object> getProperties() {
return properties;
}
@Override
public String toString() {
return MessageFormat.format("[sectionID={0}, link address={1}]", id, linkAddress.toHexAddressString()); //$NON-NLS-1$);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Section other = (Section) obj;
if (linkAddress != other.linkAddress)
return false;
if (id != other.id)
return false;
return true;
}
public String getName() {
return "" + getId();
}
public IAddress getAddress() {
return getLinkAddress();
}
public int compareTo(Object o) {
if (equals(o)) {
return 0;
}
if (o instanceof Section) {
return getAddress().compareTo(((Section)o).getAddress());
}
return -1;
}
}