Java Doc for GeneratedFilesHelper.java in  » IDE-Netbeans » project.ant » org » netbeans » spi » project » support » ant » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » project.ant » org.netbeans.spi.project.support.ant 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.netbeans.spi.project.support.ant.GeneratedFilesHelper

GeneratedFilesHelper
final public class GeneratedFilesHelper (Code)
Helps a project type (re-)generate, and manage the state and versioning of, build.xml and build-impl.xml.
author:
   Jesse Glick


Field Summary
final public static  StringBUILD_IMPL_XML_PATH
     Relative path from project directory to the implementation build script, build-impl.xml.
final public static  StringBUILD_XML_PATH
     Relative path from project directory to the user build script, build.xml.
final public static  intFLAG_MISSING
     A build script is missing from disk.
final public static  intFLAG_MODIFIED
     A build script has been modified since last generated by GeneratedFilesHelper.generateBuildScriptFromStylesheet .
final public static  intFLAG_OLD_PROJECT_XML
     A build script was generated from an older version of project.xml.
final public static  intFLAG_OLD_STYLESHEET
     A build script was generated from an older version of a stylesheet.
final public static  intFLAG_UNKNOWN
     The build script exists, but nothing else is known about it.
final static  StringGENFILES_PROPERTIES_PATH
     Path to file storing information about generated files. It should be kept in version control, since it applies equally after a fresh project checkout; it does not apply to running Ant, so should not be in project.properties; and it includes a CRC of project.xml so it cannot be in that file either.

Constructor Summary
public  GeneratedFilesHelper(AntProjectHelper h)
     Create a helper based on the supplied project helper handle.
public  GeneratedFilesHelper(AntProjectHelper h, AntBuildExtender ex)
     Create a helper based on the supplied project helper handle.
public  GeneratedFilesHelper(FileObject d)
     Create a helper based only on a project directory.

Method Summary
static  StringcomputeCrc32(InputStream is)
     Compute the CRC-32 of the contents of a stream.
public  voidgenerateBuildScriptFromStylesheet(String path, URL stylesheet)
     Create build.xml or nbproject/build-impl.xml from project.xml plus a supplied XSLT stylesheet. This is the recommended way to create the build scripts from project metadata.

You may wish to first check GeneratedFilesHelper.getBuildScriptState to decide whether you really want to overwrite an existing build script.

public  intgetBuildScriptState(String path, URL stylesheet)
     Find what state a build script is in. This may be used by a project type provider to decide whether to create or overwrite it, and whether to produce a backup in the latter case. Various abnormal conditions are detected: GeneratedFilesHelper.FLAG_MISSING , GeneratedFilesHelper.FLAG_MODIFIED , GeneratedFilesHelper.FLAG_OLD_PROJECT_XML , GeneratedFilesHelper.FLAG_OLD_STYLESHEET , and GeneratedFilesHelper.FLAG_UNKNOWN .

Currently GeneratedFilesHelper.FLAG_MODIFIED , GeneratedFilesHelper.FLAG_OLD_STYLESHEET , and GeneratedFilesHelper.FLAG_OLD_PROJECT_XML are detected by computing a CRC-32 of the script when it is created, as well as the CRC-32s of the stylesheet and project.xml.

public  booleanrefreshBuildScript(String path, URL stylesheet, boolean checkForProjectXmlModified)
     Convenience method to refresh a build script if it can and should be.

Field Detail
BUILD_IMPL_XML_PATH
final public static String BUILD_IMPL_XML_PATH(Code)
Relative path from project directory to the implementation build script, build-impl.xml.



BUILD_XML_PATH
final public static String BUILD_XML_PATH(Code)
Relative path from project directory to the user build script, build.xml.



FLAG_MISSING
final public static int FLAG_MISSING(Code)
A build script is missing from disk. This is mutually exclusive with the other flags.
See Also:   GeneratedFilesHelper.getBuildScriptState



FLAG_MODIFIED
final public static int FLAG_MODIFIED(Code)
A build script has been modified since last generated by GeneratedFilesHelper.generateBuildScriptFromStylesheet .

Probably this means it was edited by the user.


See Also:   GeneratedFilesHelper.getBuildScriptState



FLAG_OLD_PROJECT_XML
final public static int FLAG_OLD_PROJECT_XML(Code)
A build script was generated from an older version of project.xml. It was last generated using a different version of project.xml, so using the current project.xml might produce a different result.

This is quite likely in the case of build.xml; in the case of build-impl.xml, it probably means that the user edited project.xml manually, since if that were modified from AntProjectHelper methods and the project were saved, the script would have been regenerated already.


See Also:   GeneratedFilesHelper.getBuildScriptState



FLAG_OLD_STYLESHEET
final public static int FLAG_OLD_STYLESHEET(Code)
A build script was generated from an older version of a stylesheet. It was last generated using a different (probably older) version of the XSLT stylesheet, so using the current stylesheet might produce a different result.

Probably this means the project type provider module has been upgraded since the project was last saved (in the case of build-impl.xml) or created (in the case of build.xml).


See Also:   GeneratedFilesHelper.getBuildScriptState



FLAG_UNKNOWN
final public static int FLAG_UNKNOWN(Code)
The build script exists, but nothing else is known about it. This flag is mutually exclusive with GeneratedFilesHelper.FLAG_MISSING but when set also sets GeneratedFilesHelper.FLAG_MODIFIED , GeneratedFilesHelper.FLAG_OLD_STYLESHEET , and GeneratedFilesHelper.FLAG_OLD_PROJECT_XML - since it is not known whether these conditions might obtain, it is safest to assume they do.

Probably this means that nbproject/genfiles.properties was deleted by the user.


See Also:   GeneratedFilesHelper.getBuildScriptState



GENFILES_PROPERTIES_PATH
final static String GENFILES_PROPERTIES_PATH(Code)
Path to file storing information about generated files. It should be kept in version control, since it applies equally after a fresh project checkout; it does not apply to running Ant, so should not be in project.properties; and it includes a CRC of project.xml so it cannot be in that file either. It could be stored in some special comment at the end of the build script (e.g.) but many users would just compulsively delete it in this case since it looks weird.




Constructor Detail
GeneratedFilesHelper
public GeneratedFilesHelper(AntProjectHelper h)(Code)
Create a helper based on the supplied project helper handle.
Parameters:
  h - an Ant-based project helper supplied to the project type provider



GeneratedFilesHelper
public GeneratedFilesHelper(AntProjectHelper h, AntBuildExtender ex)(Code)
Create a helper based on the supplied project helper handle. The created instance is capable of extending the generated files with 3rd party content.
Parameters:
  h - an Ant-based project helper supplied to the project type provider
Parameters:
  ex - build extensibility support
since:
   org.netbeans.modules.project.ant 1.16



GeneratedFilesHelper
public GeneratedFilesHelper(FileObject d)(Code)
Create a helper based only on a project directory. This can be used to perform the basic refresh functionality without being the owner of the project. It is only intended for use from the offline Ant task to refresh a project, and similar special situations. For normal circumstances please use only GeneratedFilesHelper.GeneratedFilesHelper(AntProjectHelper) .
Parameters:
  d - the project directory
throws:
  IllegalArgumentException - if the supplied directory has no project.xml




Method Detail
computeCrc32
static String computeCrc32(InputStream is) throws IOException(Code)
Compute the CRC-32 of the contents of a stream. \r\n and \r are both normalized to \n for purposes of the calculation.



generateBuildScriptFromStylesheet
public void generateBuildScriptFromStylesheet(String path, URL stylesheet) throws IOException, IllegalStateException(Code)
Create build.xml or nbproject/build-impl.xml from project.xml plus a supplied XSLT stylesheet. This is the recommended way to create the build scripts from project metadata.

You may wish to first check GeneratedFilesHelper.getBuildScriptState to decide whether you really want to overwrite an existing build script. Typically if you find GeneratedFilesHelper.FLAG_MODIFIED you should not overwrite it; or ask for confirmation first; or make a backup. Of course if you find neither of GeneratedFilesHelper.FLAG_OLD_STYLESHEET nor GeneratedFilesHelper.FLAG_OLD_PROJECT_XML then there is no reason to overwrite the script to begin with.

Acquires write access.


Parameters:
  path - a project-relative file path such as GeneratedFilesHelper.BUILD_XML_PATH or GeneratedFilesHelper.BUILD_IMPL_XML_PATH
Parameters:
  stylesheet - a URL to an XSLT stylesheet accepting project.xmlas input and producing the build script as output
throws:
  IOException - if transforming or writing the output failed
throws:
  IllegalStateException - if the project was modified (and not being saved)



getBuildScriptState
public int getBuildScriptState(String path, URL stylesheet) throws IllegalStateException(Code)
Find what state a build script is in. This may be used by a project type provider to decide whether to create or overwrite it, and whether to produce a backup in the latter case. Various abnormal conditions are detected: GeneratedFilesHelper.FLAG_MISSING , GeneratedFilesHelper.FLAG_MODIFIED , GeneratedFilesHelper.FLAG_OLD_PROJECT_XML , GeneratedFilesHelper.FLAG_OLD_STYLESHEET , and GeneratedFilesHelper.FLAG_UNKNOWN .

Currently GeneratedFilesHelper.FLAG_MODIFIED , GeneratedFilesHelper.FLAG_OLD_STYLESHEET , and GeneratedFilesHelper.FLAG_OLD_PROJECT_XML are detected by computing a CRC-32 of the script when it is created, as well as the CRC-32s of the stylesheet and project.xml. These CRCs are stored in a special file nbproject/genfiles.properties. The CRCs are based on the textual contents of the files (so even changed to whitespace etc. are considered changes), but are independent of platform newline conventions (since e.g. CVS will by default replace \n with \r\n when checking out on Windows). Changes to external files included into project.xml or the stylesheet (e.g. using XSLT's import facility) are not detected.

If there is some kind of I/O error reading any files, GeneratedFilesHelper.FLAG_UNKNOWN is returned (in conjunction with GeneratedFilesHelper.FLAG_MODIFIED , GeneratedFilesHelper.FLAG_OLD_STYLESHEET , and GeneratedFilesHelper.FLAG_OLD_PROJECT_XML to be safe).

Acquires read access.


Parameters:
  path - a project-relative path such as GeneratedFilesHelper.BUILD_XML_PATH or GeneratedFilesHelper.BUILD_IMPL_XML_PATH
Parameters:
  stylesheet - a URL to an XSLT stylesheet accepting project.xmlas input and producing the build script as output(should match that given to GeneratedFilesHelper.generateBuildScriptFromStylesheet) a bitwise OR of various flags, or 0 if the scriptis present on disk and fully up-to-date
throws:
  IllegalStateException - if the project was modified



refreshBuildScript
public boolean refreshBuildScript(String path, URL stylesheet, boolean checkForProjectXmlModified) throws IOException, IllegalStateException(Code)
Convenience method to refresh a build script if it can and should be.

If the script is not modified, and it is either missing, or the flag checkForProjectXmlModified is false, or it is out of date with respect to either project.xml or the stylesheet (or both), it is (re-)generated.

Acquires write access.

Typical usage from ProjectXmlSavedHook.projectXmlSaved is to call this method for both GeneratedFilesHelper.BUILD_XML_PATH and GeneratedFilesHelper.BUILD_IMPL_XML_PATH with the appropriate stylesheets and with checkForProjectXmlModified false (the script is certainly out of date relative to project.xml). Typical usage from org.netbeans.spi.project.ui.ProjectOpenedHook.projectOpened is to call this method for both scripts with the appropriate stylesheets and with checkForProjectXmlModified true.


Parameters:
  path - a project-relative path such as GeneratedFilesHelper.BUILD_XML_PATH or GeneratedFilesHelper.BUILD_IMPL_XML_PATH
Parameters:
  stylesheet - a URL to an XSLT stylesheet accepting project.xmlas input and producing the build script as output
Parameters:
  checkForProjectXmlModified - true if it is necessary to check whether thescript is out of date with respect toproject.xml and/or the stylesheet true if the script was in fact regenerated
throws:
  IOException - if transforming or writing the output failed
throws:
  IllegalStateException - if the project was modified



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.