blob: a82a236481d94b1240d8c148964281fdcdbbc1fb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/*******************************************************************************
* Copyright (c) 2007, 2008 Symbian Software Limited and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.templateengine.process.processes;
import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* Creates a template macro value that can be used as a pseudo-unique resource identifier.
* It is based on the name of the application and is in the form of four capital letters.
* e.g. Helloworld => HELL
*/
public class CreateResourceIdentifier extends ProcessRunner {
@Override
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor)
throws ProcessFailureException {
String valueName = args[0].getSimpleValue();
String appName = args[1].getSimpleValue();
String value = ""; //$NON-NLS-1$
if (appName.length() >= 4) {
value = appName.substring(0, 4).toUpperCase();
} else {
value = appName.toUpperCase();
for (int i = 0; i < 4 - appName.length(); i++) {
value = value + "X"; //$NON-NLS-1$
}
}
template.getValueStore().put(valueName, value);
}
}
|