1
/*******************************************************************************
2
* Copyright (c) 2003, 2007 IBM Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* IBM - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.managedbuilder.internal.core;
14
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
15
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
16
import org.osgi.framework.Version;
18
public class BuildObject implements IBuildObject {
21
protected String name;
22
private String baseId=null;
24
protected Version version = null;
25
protected String managedBuildRevision = null;
28
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
30
public String getId() {
35
* @see org.eclipse.cdt.core.build.managed.IBuildObject#setId(java.lang.String)
37
public void setId(String id) {
42
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
44
public String getName() {
49
* @see org.eclipse.cdt.core.build.managed.IBuildObject#setName(java.lang.String)
51
public void setName(String name) {
56
* @see java.lang.Object#toString()
59
public String toString() {
64
* @return Returns the managedBuildRevision.
66
public String getManagedBuildRevision() {
67
return managedBuildRevision;
71
* @return Returns the version.
73
public Version getVersion() {
78
* @param version The version to set.
80
public void setVersion(Version version) {
81
this.version = version;
85
* @return id of the object this class was based on. Note that this function
86
* assumes that id was generated by {@link ManagedBuildManager#calculateChildId(String, String)}.
88
public String getBaseId() {
90
baseId = ManagedBuildManager.calculateBaseId(id);
95
public Version getVersionFromId() {
96
String versionNumber = ManagedBuildManager.getVersionFromIdAndVersion( getId());
98
if( versionNumber == null) {
99
// It means, Tool Integrator either not provided version information in 'id' or provided in wrong format,
100
// So get the default version based on 'managedBuildRevision' attribute.
102
if ( getManagedBuildRevision() != null) {
103
Version tmpManagedBuildRevision = new Version( getManagedBuildRevision() );
104
if (tmpManagedBuildRevision.equals(new Version("1.2.0")) ) //$NON-NLS-1$
105
versionNumber = "0.0.1"; //$NON-NLS-1$
106
else if (tmpManagedBuildRevision.equals(new Version("2.0.0")) ) //$NON-NLS-1$
107
versionNumber = "0.0.2"; //$NON-NLS-1$
108
else if (tmpManagedBuildRevision.equals(new Version("2.1.0")) ) //$NON-NLS-1$
109
versionNumber = "0.0.3"; //$NON-NLS-1$
111
versionNumber = "0.0.4"; //$NON-NLS-1$
113
versionNumber = "0.0.0"; //$NON-NLS-1$
116
return new Version(versionNumber);
119
public void setManagedBuildRevision(String managedBuildRevision) {
120
this.managedBuildRevision = managedBuildRevision;
124
* updates revision for this build object and all its children
126
public void updateManagedBuildRevision(String revision){
127
setManagedBuildRevision(revision);
128
setVersion(getVersionFromId());