| /******************************************************************************* |
| * 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 properties to ctor & getProperties() to API |
| *******************************************************************************/ |
| package org.eclipse.cdt.debug.edc.internal.symbols; |
| |
| import java.util.HashMap; |
| import java.util.Map; |
| |
| import org.eclipse.cdt.core.IAddress; |
| import org.eclipse.cdt.debug.edc.symbols.AbstractAddressInterval; |
| import org.eclipse.cdt.debug.edc.symbols.ISymbol; |
| |
| public class Symbol extends AbstractAddressInterval implements ISymbol { |
| |
| protected String name; |
| protected IAddress address; |
| protected long size; |
| |
| private Map<String, Object> properties; |
| |
| /** |
| * use {@link Symbol#Symbol(String, IAddress, long, Map)} to supply |
| * an already available set of properties |
| * @param name |
| * @param address |
| * @param size |
| */ |
| public Symbol(String name, IAddress address, long size) { |
| this(name, address, size, new HashMap<String, Object>(0)); |
| } |
| |
| /** |
| * @param name |
| * @param address |
| * @param size |
| * @param properties |
| */ |
| public Symbol(String name, IAddress address, long size, Map<String,Object> properties) { |
| this.name = name; |
| this.address = address; |
| this.size = size; |
| this.properties = properties; |
| } |
| |
| public String getName() { |
| return name; |
| } |
| |
| public IAddress getAddress() { |
| return address; |
| } |
| |
| public long getSize() { |
| return size; |
| } |
| |
| public int compareTo(Object o) { |
| if (o instanceof Symbol) { |
| return address.compareTo(((Symbol) o).address); |
| } else if (o instanceof IAddress) { |
| return address.compareTo(o); |
| } |
| return 0; |
| } |
| |
| @Override |
| public String toString() { |
| return "name=" + name + //$NON-NLS-1$ |
| ", address=0x" + Long.toHexString(address.getValue().longValue()) + //$NON-NLS-1$ |
| ", size=" + size; //$NON-NLS-1$ |
| } |
| public Map<String, Object> getProperties() { |
| return properties; |
| } |
| } |