1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
32
package com.sun.grid.cull;
35
import java.util.logging.Level;
40
public class CullConstantConverter extends AbstractCullToJavaConverter {
43
System.loadLibrary("drmaa");
46
/** Creates a new instance of CullConstantConverter */
47
public CullConstantConverter() {
50
public void convert(CullDefinition cullDef) throws java.io.IOException {
52
String packagename = getPackagename();
53
String className = "CullConstants";
54
File file = getFileForClass(className);
55
boolean dirty = false;
58
for (String nss : cullDef.getNameSpaceNameSet()) {
59
CullNameSpace ns = cullDef.getNameSpace(nss);
60
File defFile = cullDef.getNameSource(ns.getNameSpace());
61
if (defFile == null) {
62
logger.log(Level.WARNING, "no source file for namespace " + ns.getNameSpace() + " found");
63
} else if (defFile.lastModified() > file.lastModified()) {
64
logger.log(Level.FINE, "namespace " + ns.getNameSpace() + " is dirty (defined in " + defFile + ")");
68
logger.log(Level.FINE, "namespace " + ns.getNameSpace() + " is up to date");
76
Printer p = new Printer(file);
78
p.println("/* Generated by " + getClass().getName());
80
if (packagename != null) {
86
p.print("public interface ");
91
for (String nss : cullDef.getNameSpaceNameSet()) {
92
CullNameSpace ns = cullDef.getNameSpace(nss);
93
writeNameSpace(ns, p);
103
private void writeNameSpace(CullNameSpace ns, Printer p) {
105
for (String name : ns.getNames()) {
106
p.print("public static final int ");
107
// p.print( ns.getNameSpace() );
111
p.print(strToNm(name));
116
private native int strToNm(String name);