Custom Taglets and static class fields/methods...

Hey all,
I have a curiosity question (running winxp + j2sdk 1.4.2_04).
I have written a few stand-alone and inline taglets to help me document my code. I had some problems initially getting the HTML to output correctly (and I don't know how to run javadoc in the debugger) so I wrote a simple class with only static methods/members that tracks the nesting level of the current tag and allows me to pad (prefix) the output based on the nesting level (rudimentary I know). I wasn't sure if the javadoc process was multi-threaded or not, so all methods are synchronized.
My problem is that the static initializer is being called 6 different times during the execution of javadoc.exe, resulting in what I would term as 6 "static" instances. Now, the only reason I can think of for this is that it is spinning off new process for each type of taglet it encounters. However, processing seems sequential and I don't see any other processes in Windows Task Manager. Here is the static initializer code:
     static {
          ic = new IndentControl();
          System.out.println("static: " + Thread.currentThread() + " ic instance: " + ic);
and here is the output of javadoc.exe:
     static: Thread[main,5,main] ic instance: ndstest.util.javadoc.IndentControl@33c78b
     Registered Taglet ndstest.util.javadoc.MandatoryTaglet ...
     static: Thread[main,5,main] ic instance: ndstest.util.javadoc.IndentControl@6c137c
     Registered Taglet ndstest.util.javadoc.OptionalTaglet ...
     static: Thread[main,5,main] ic instance: ndstest.util.javadoc.IndentControl@1104da7
     Registered Taglet ndstest.util.javadoc.MemberInlineTaglet ...
     static: Thread[main,5,main] ic instance: ndstest.util.javadoc.IndentControl@6745b9
     Registered Taglet ndstest.util.javadoc.DescriptionInlineTaglet ...
     static: Thread[main,5,main] ic instance: ndstest.util.javadoc.IndentControl@10a14ad
     Registered Taglet ndstest.util.javadoc.ExampleTaglet ...
     static: Thread[main,5,main] ic instance: ndstest.util.javadoc.IndentControl@1afe460
     Registered Taglet ndstest.util.javadoc.ToDoTaglet ...
Why does the static initializer get called 6 different times? It's mildly annoying and I want to understand why and if it is something I am doing to cause this.
Thanks!

Well, have you ever taken a look at the implementation of the Standard doclet? (Its source code is part of the SCSL distribution.)
The current implemenatation uses a TagletManager to handle/store/load custom taglets.
For each -taglet option, method addCustomTag of this TagletManager is called.
This method creates a new instance of UrlClassLoader and uses loadClass( className ) to load the taglet each time it is called.
So, each of your six taglets is loaded through/in a different ClassLoader context, therefore the static init block is executed six times.

Similar Messages

  • Singleton pattern class and static class

    Hi,
    what is difference between the singleton pattern class and static class ?
    in singleton pattern, we declare a static member[which hold one value at a time] ,static method[ which return static member value] and a private constructor[not allow to direct instantiation]. My words are -- as a singleton pattern we implement static class .
    so can we say a singleton pattern is static class it means both are same or is any difference between these two ??

    malcolmmc wrote:
    On several occasions I've had to convert a static (never instanceated) class to a singleton type, for example because I realise I need an instance per thread, or I decide to make a program more modular, with more than one configuration.
    I've never done the opposite.
    So generally I favour the singleton if there any "state" involved, because it's more flexible in unanticipated directions. It also gives extra flexibility when building tests, especially if you program to an interface.Total agreement; if anything it is dead hard to override static method logic with mock code in unit tests (I had to do it by keeping the static methods in place but making them internally use a singleton instance of itself of which the instance variable could be overwritten with a mock implementation for unit testing purposes...).
    'Static classes' and/or methods are great for very simple util functions, but I wouldn't use them for anything other than that.

  • Copy data customer PO and PO date field from quotation to sales order

    Hi Friends,
    Can you please let me know what copy control settings I need to maintain in order to copy customer PO# and PO date field data in quotation to sales order.
    All the data is getting copied from quotation to sales order when I create sales order with reference to quotation but the customer PO no. and PO date is not getting copied.
    Can anyone please help.
    Regards,
    Wasim.

    HI
    Not sure if this is possible via Customization or not but you can try the user-exits or Routines for the Sales Order program for this
    You need to change the include FV45C102 (assuming you have copied standard order and the copy controls). ABAP team should be able to make changes to this routine and achieve your requirement.
    In VTAA, after choosing the Source and Target order type and choosing the right Quatation item, check the routine for 'Bus.data/item compl.' and it will be what has been mentioned above.
    Please check &Revert
    Thanks&Regards
    Raghu.k

  • Custom User and Group classes

    Hi,
    I have a login custom module which does the authentication for my application.
    Till now I was using WLSUserImpl and WLSGroupIpml and everything was working fine.
    Now to make the LoginModule weblogic independent , I replaced the User and Group
    classes with my own classes which extend from java.security.Principal.
    But for some reason this isnt working. Am I missing something obvious.??
    This the exception stack trace which I get
    java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[com.isone.security.providers.authentication.ISOUser@1698cbe,
    com.isone.security.providers.authentication.ISOGroup@9719f4, com.isone.security.providers.authentication.ISOGroup@28ebb4,
    com.isone.security.providers.authentication.ISOGroup@8ab721, com.isone.security.providers.authentication.ISOGroup@fcf06c,
    com.isone.security.providers.authentication.ISOGroup@c7539, com.isone.security.providers.authentication.ISOGroup@1e41830,
    com.isone.security.providers.authentication.ISOGroup@1f01b29, com.isone.security.providers.authentication.ISOGroup@8721bd,
    com.isone.security.providers.authentication.ISOGroup@1b81d4f, com.isone.security.providers.authentication.ISOGroup@8c6e04,
    com.isone.security.providers.authentication.ISOGroup@18aeabe, com.isone.security.providers.authentication.ISOGroup@13968f1,
    com.isone.security.providers.authentication.ISOGroup@18c28a, com.isone.security.providers.authentication.ISOGroup@18bff68,
    com.isone.security.providers.authentication.ISOGroup@2d2da4]
         at weblogic.security.service.SecurityServiceManager.seal(SecurityServiceManager.java:682)
         at weblogic.security.service.RoleManager.getRoles(RoleManager.java:279)
         at weblogic.security.service.AuthorizationManager.isAccessAllowed(AuthorizationManager.java:694)
         at weblogic.servlet.security.internal.WebAppSecurity.hasPermission(WebAppSecurity.java:567)
         at weblogic.servlet.security.internal.SecurityModule.checkPerm(SecurityModule.java:134)
         at weblogic.servlet.security.internal.FormSecurityModule.checkUserPerm(FormSecurityModule.java:327)
         at weblogic.servlet.security.internal.SecurityModule.beginCheck(SecurityModule.java:182)
         at weblogic.servlet.security.internal.FormSecurityModule.checkA(FormSecurityModule.java:181)
         at weblogic.servlet.security.internal.ServletSecurityManager.checkAccess(ServletSecurityManager.java:145)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3539)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

    And this will explain you why there is no way to do this right now:
    (CR125681 -- although it says 7.0SP1 it is not fixed even in 8.1 SP2 and
    there is no time frame for the fix)
    http://support.bea.com/application?namespace=askbea&origin=ask_bea_answer.jsp&event=link.view_answer_page_clfydoc&answerpage=solution&page=wls/S-21705.htm
    We've had the same issue and even have an open support case and for now
    the only way to workaround the bug is to
    use the WLSUserImpl and WLSGroupImpl classes.
    HTH,
    Dejan
    Pavel wrote:
    See if this will help:
    http://edocs.bea.com/wls/docs81/dvspisec/pv.html
    Pavel.
    "Anil" <[email protected]> wrote:
    I actually extended PrincipalValidatorImpl and returned java.security.Principal
    as the base class.
    But still I got the same exception.
    PaulF <paulf@reply_in_newsgroup.com> wrote:
    On 25 Feb 2004 06:45:50 -0800, Anil <[email protected]> wrote:
    Hi,
    I have a login custom module which does the authentication for my
    application.
    Till now I was using WLSUserImpl and WLSGroupIpml and everything was
    working fine.
    Now to make the LoginModule weblogic independent , I replaced the
    User
    and Group
    classes with my own classes which extend from java.security.Principal.
    But for some reason this isnt working. Am I missing something obvious.??
    This the exception stack trace which I get
    java.lang.SecurityException: [Security:090398]Invalid Subject:
    principals=[com.isone.security.providers.authentication.ISOUser@1698cbe,
    com.isone.security.providers.authentication.ISOGroup@9719f4,
    com.isone.security.providers.authentication.ISOGroup@28ebb4,
    com.isone.security.providers.authentication.ISOGroup@8ab721,
    com.isone.security.providers.authentication.ISOGroup@fcf06c,
    com.isone.security.providers.authentication.ISOGroup@c7539,
    com.isone.security.providers.authentication.ISOGroup@1e41830,
    com.isone.security.providers.authentication.ISOGroup@1f01b29,
    com.isone.security.providers.authentication.ISOGroup@8721bd,
    com.isone.security.providers.authentication.ISOGroup@1b81d4f,
    com.isone.security.providers.authentication.ISOGroup@8c6e04,
    com.isone.security.providers.authentication.ISOGroup@18aeabe,
    com.isone.security.providers.authentication.ISOGroup@13968f1,
    com.isone.security.providers.authentication.ISOGroup@18c28a,
    com.isone.security.providers.authentication.ISOGroup@18bff68,
    com.isone.security.providers.authentication.ISOGroup@2d2da4]
         at
    weblogic.security.service.SecurityServiceManager.seal(SecurityServiceManager.java:682)
         at weblogic.security.service.RoleManager.getRoles(RoleManager.java:279)
         at
    weblogic.security.service.AuthorizationManager.isAccessAllowed(AuthorizationManager.java:694)
         at
    weblogic.servlet.security.internal.WebAppSecurity.hasPermission(WebAppSecurity.java:567)
         at
    weblogic.servlet.security.internal.SecurityModule.checkPerm(SecurityModule.java:134)
         at
    weblogic.servlet.security.internal.FormSecurityModule.checkUserPerm(FormSecurityModule.java:327)
         at
    weblogic.servlet.security.internal.SecurityModule.beginCheck(SecurityModule.java:182)
         at
    weblogic.servlet.security.internal.FormSecurityModule.checkA(FormSecurityModule.java:181)
         at
    weblogic.servlet.security.internal.ServletSecurityManager.checkAccess(ServletSecurityManager.java:145)
         at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3539)
         at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    I think that you need to extend WLSAbstractPrincipal I think instead
    of
    WLSPrincipal if you aren't going to implement your own
    PrincipalValidator. The default PrincipalValidator is going to expect
    a
    principal that extends WLSAbstractPrincipal.
    PaulF
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

  • Singletons and Static class behavior

    Hi all and thanks for taking a look at this,
    I was playing around with a Singleton class today and it raised raised a few questions around Static methods in the singleton. When my class is instatiated I load some data into a HashMap map that I want to make available for read only purposes through other methods in my singleton.
    I really wanted to just call a static method to look up the value, so I followed the standard model. I had a private static HashMap that is loaded with data when the Contructor is called from the getInstance(). I included the standard model example for you if you wanted to refer to it.
    I ran my code making a static MyClass.getData() call to see what would happen. The static call did not return a value, I wasn't surprised. Then I added a call to MyClass.getInstance() followed by the static MyClass.getData() call and this returned the appropriate value.
    Then I changed my Singleton as follows and was wondering if there were any issues that might result because of this and I was wondering what the process that is followed by java when calling a static method (what does it use, where does it look).
    My Code:
    public class MyClass {
    private static MyClass instance;
    private static HashMap myData;
    private MyClass() {
    myData = new HashMap();
    myData.put("1", "value 1");
    myData.put("2", "value 2");
    private static synchronized void getInstance() {
    if (instance == null)
    instance = new MyClass();
    public static String getData(String key) {
    if (myData == null)
    getInstance();
    return (String)myData.get(key);
    The standard singleton model class:
    public class MyClass {
    private static MyClass instance;
    private MyClass() { }
    public static synchronized MyClass getInstance() {
    if (instance == null)
    instance = new MyClass();
    return instance;
    ... rest of methods (not static)
    }

    Thanks for the reply,
    Really my only reason for making it static was so the calling class would not have to get a handle to the actual MyClass Instance. Therefore avoiding the Synchronization method.
    I was attempting to aviod the famous broken double check locking by having the checks in different methods. I am assuming from you warning that keeping the methods seperate and synchronizing the getInstance is really no different than putting a synchronize(this) block around the second check and the constructor call?
    Really my objective is to retrive data once, not really create a single access point for getting the data. As an alternative, I tried the following code and it seems to work, any issues you can see with this?
    public class MyClass {
    private static HashMap hm;
    static {
    hm = new HashMap();
    // code to get Data into HashMap
    public static String getData(String key) {
    return hm.get(key);

  • Event Receiver to create a List based on a custom template and on lookup field

    Hi
    I would like to have an Event Receiver who is firing by addItem in a list calls Seminarliste and is creating each time a new list based on three columns for add.Lists("Title of the list", "Description of the list", "Custom List
    Template")
    I have a Problem to get the LookupField Title and I am getting a Problem to create a list.
    If I debug the code the bold line creates an exception ;(
    The following code I have produced:
            public override void ItemAdding(SPItemEventProperties properties)
                base.ItemAdding(properties);
                SPWeb spCurrentSite = properties.OpenWeb();
                SPSite siteCollection = new SPSite("http://win-ue32d37ap2n");
                SPWeb web = siteCollection.OpenWeb();
                SPListCollection lists = web.Lists;
                String curListName = properties.ListTitle;
                if(curListName == "Seminarliste")
                    SPListItem curItem = properties.ListItem;
                    String curItemListName = properties.AfterProperties["Title"].ToString();
                    String curItemDescription = properties.AfterProperties["Beschreibung"].ToString();
                    // Lookup field with Option to Chose a template name
                    String curItemTemplate = properties.AfterProperties["Template"].ToString();
                    SPListTemplateCollection listTemplates = siteCollection.GetCustomListTemplates(web);
                    //Error by following line ...
    SPListTemplate myTemplate = listTemplates[curItemTemplate];
                    web.Lists.Add(curItemListName, curItemDescription, myTemplate);
    If somebody had a similar problem in the past and could advice it would be most appreciated ;-)
    Thanks in advance ;-)
    Kind regards Michael Damaschke

    If I understand correctly, the field you use to select the template name is a lookup field? If so, then the problem is the lookup field value is not the name of the template. It is an SPFieldLookupValue, which contains the ID and the string of the lookup.
    So you want to separate the template name, like this:
    if (item["LookupField"] !=
    null)
         string fieldValue = item["LookupField"].ToString();
         SPFieldLookupValue value =
    new SPFieldLookupValue(fieldValue);
         int lookupListItemID = value.LookupId;
         string lookupListValue = value.LookupValue;
    IF you look at the fieldValue above, you will see it is something like an integer, followed by delimiter ;# and then your template name. you can always just parse the string at the ;# as well if you were so inclined.

  • Binding a subtree using custom State- and ObjectFactory

    Hi,
    first of all a very short example to illustrate my idea. I know that it would be complete rubbish to store the kind of data in the example in multiple classes and ldap entries. Currently I'm working with much larger objects that must be written according to special schema definitions. This example is really only for illustration!
    LDAP-Schema:
    objectclass ( 1.3.6.1.4.1... NAME 'myperson'
                  SUP top STRUCTURAL
                  MUST ( cn $ sn ) MAY ( email ) )
    objectclass ( 1.3.6.1.4.1... NAME 'myphoto'
                  SUP top STRUCTURAL
                  MUST ( cn $ jpegPhoto ) )
    Java-Classes:
    class MyPhoto {
        byte[] photo;
    class MyPerson {
        String cn;
        String sn;
        String email;
        MyPhoto photo; // This is the really relevant line :)
    }Now to the question:
    Is it possible to bind multiple java objects with one call to bind and to get a subtree by using custom State- and ObjectFactory-Classes?
    Structure of the LDAP-Database
    dn: cn=John Doe
    {  cn=John Doe
       sn=Doe
       [email protected]   }
    dn: cn=TheLogo, cn=John Doe    // Child of cn=John Doe
    { cn=TheLogo              // The cn is the same for all MyPhoto entries
                              // its only use is for building the dn
      jpegPhoto=[some binary data]   }I tried to solve the problem with a kind of recursion. When my StateFactory is called to bind an Object of Class MyPerson it builds the appropriate AttributeList. Before it returns, it calls bind for the Object of class MyPhoto with the dn: "cn=TheLogo,cn=John Doe".
    Of course this doesn't work because the entry for cn="John Doe" doesn't exist at this time. Now I don't know what to do. A possible solution would be to create everything by hand, but then I wouldn't have to use custom StateFactories at all. But if there is a simple solution to my problem I would like to use my own StateFactory instead of having to implement a persistance manager on my own.
    I hope you understand what I want to do and why it doesn't work out. If you don't please ask and I will try to clarify.

    Hello,
    A provisional solution is to use an external controller. For this approach to work, each class has to provide the list of objects being part of its properties. I have prepared two interfaces for this purpose:
    public interface HasSubordinates {
    Enumeration getSubordinates();
    boolean hasSubordinates();
    public interface Storable extends HasSubordinates {
    String getIdentifier();
    Then, you can use the controller to recursively get the object "tree" and store it in the directory (either using objects that implement the DirContext interface or using StateFactories - the last one is the one I have used)
    The code for the Controller is the following:
    import javax.naming.*;
    import javax.naming.directory.*;
    import javax.naming.spi.*;
    import java.util.*;
    import java.io.IOException;
    public class DatabaseAccessController {
    // Constants
    final static String ldapServerName = "localhost";
    final static String rootdn = "cn=juanluis, o=niaf";
    final static String rootpass = "secret";
    final static String rootContext = "o=niaf";
    private DirContext initialContext;
    private static Properties env = new Properties();
    static {
    env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
    env.put( Context.STATE_FACTORIES, "database.PersonStateFactory:database.AddressStateFactory");
    env.put( Context.PROVIDER_URL, "ldap://"+ ldapServerName+"/"+rootContext);
    env.put( Context.SECURITY_PRINCIPAL, rootdn );
    env.put( Context.SECURITY_CREDENTIALS, rootpass );
    public DatabaseAccessController() {
    try {
    initialContext = new InitialDirContext( env );
    } catch( Exception e ) {
    e.printStackTrace();
    public void store( Storable object ) {   
    try {
    store( object, initialContext );
    } catch( NamingException ne ) {
    ne.printStackTrace();
    private void store( Storable object, DirContext ctx ) throws NamingException{
    DirStateFactory.Result result = DirectoryManager.getStateToBind( object, null, null, env, null );
    Attributes attributes = result.getAttributes();
    DirContext new_ctx = ctx.createSubcontext( dn(object), attributes );
    if( object.hasSubordinates() ) {
    Enumeration subordinates = object.getSubordinates();
    while( subordinates.hasMoreElements() ) {
    try {
    store( (Storable)subordinates.nextElement(), new_ctx );
    } catch( Exception e ) {
    e.printStackTrace();
    private String dn( Storable object ) {
    return "cn="+object.getIdentifier();
    This is an example of how it should work on two objects:
    public class Person implements Storable{
    String name;
    String surname;
    Address address;
    public Person(String n, String sn, Address addr) {
    name = n;
    surname = sn;
    address = addr;
    public boolean hasSubordinates() {
    return true;
    public Enumeration getSubordinates() {
    Hashtable h = new Hashtable();
    h.put("address", address );
    return h.elements();
    public String getIdentifier() {
    return name + " "+ surname;
    public class Address implements Storable {
    String street;
    int number;
    Attributes attrs;
    public Address( String s, int n) {
    street = s;
    number = n;
    public boolean hasSubordinates() {
    return false;
    public Enumeration getSubordinates() {
    return null;
    public String getIdentifier() {
    return street + number;
    And here it is the program that access to the directory:
    public class TestLDAP {
    public TestLDAP() {
    public static void main(String[] args) {
    try {
    System.out.println("Creating controller...");
    DatabaseAccessController controller = new DatabaseAccessController();
    System.out.println("Controller created");
    Person person = new Person("Juan Luis", "Manas", new Address("Street in Madrid", 33 ));
    System.out.println("Storing object in the directory...");
    controller.store(person);
    System.out.println("object stored successfully!");
    } catch( Exception e ) {
    e.printStackTrace();
    }���
    If you find a better way of performing the storage of complex objects in the directory, please, let me know.
    Regards,
    Juan Luis

  • Custom Chrome and Custom Cursor problems

    Howdy, I've got a small problem with chrome and cursors.
    I've created my main application window with the chrome set to Custom-Opaque
    I've got my custom frame, window controls etc. all wired up and working nicely.
    I've got my cursor manager swithing the cursor to resize-arrows when you get close to the window edges.
    Here's where I run into a couple problems:
    The cursor is only visible within the bounds of the window--unlike the system chrome which gives the resize cursors outside the window bounds. Any way to use the system cursors? or another idea?
    When I resize the window, the custom cursor stays right where the MOUSE_DOWN event occured, and doesn't move with the mouse anymore. The window does resize though... Any suggestions?
    Thanks in advance!
    -Ted

    I have the same problem but I extend the WindowsLookAndFeel. I know of a way to fix this but it seems unbelievable that this is the only way. Here is how I did it: In your custom look and feel class add this method. Call the super version and then add the icons that are missing to the UIDefaults table. Of course your code would have MetalLookAndFeel where my example has WindowsLookAndFeel. Hopefully someone will come up with a better solution. I plan on raising a bug in the bug parade for this.
    protected void initComponentDefaults(UIDefaults table)
              super.initComponentDefaults(table);
              table.put("DesktopIcon.icon", LookAndFeel.makeIcon(WindowsLookAndFeel.class,"icons/DesktopIcon.gif"));
              table.put("Tree.openIcon",LookAndFeel.makeIcon(WindowsLookAndFeel.class,"icons/TreeOpen.gif"));
              table.put("Tree.closedIcon",LookAndFeel.makeIcon(WindowsLookAndFeel.class, "icons/TreeClosed.gif"));
              table.put("OptionPane.errorIcon", LookAndFeel.makeIcon(WindowsLookAndFeel.class,"icons/Error.gif"));
              table.put("OptionPane.informationIcon", LookAndFeel.makeIcon(WindowsLookAndFeel.class,"icons/Inform.gif"));
              table.put("OptionPane.warningIcon", LookAndFeel.makeIcon(WindowsLookAndFeel.class,"icons/Warn.gif"));
              table.put("OptionPane.questionIcon", LookAndFeel.makeIcon(WindowsLookAndFeel.class,"icons/Question.gif"));
              table.put("Tree.leafIcon", LookAndFeel.makeIcon(WindowsLookAndFeel.class,"icons/TreeLeaf.gif"));
    Hope this helps.

  • Abstract classes and static methods

    I have an abstract report class AbstractReportClass which I am extending in multiple report classes (one for each report, say ReportA, ReportB, ...). Each report class has its own static column definitions, title, etc., which I have to access through a static method getDataMeta() in a web application. Each report has the same exact code in getDataMeta, and no report may exist without these fields. My intuition tells me that AbstractReportClass should contain the code for getDataMeta, but I know that you can't mix abstract and static keywords.
    Am I missing a simple solution to unify the getDataMeta code in the abstract base class? or do I really need to have a static function getDataMeta with the same code in each of the base classes?
    My apologies if this has been discussed many times before.
    Thanks,
    -Andrew

    I'm not trying to be "right"; rather I just asked a question about whether I can do something that seems intuitive. Perhaps you might write code in a different way than I would or perhaps I wasn't clear about every little detail about my code? Do you regularly belittle people who ask questions here?
    I have a loadFromDB() member function in AbstractReport for which all sub classes have an overloaded version. All reports I'm displaying have 4 common fields (a database id and a name and a monetary value, for example), but then each other report has additional fields it loads from the database. Inside ReportX classes' loadFromDB(), I call the superclass loadFromDB() function and augment values to get a completely loaded object. In fact, the loadedData member object resides in AbstractReport.
    I can't use a report unless it has these common features. Every report is an AbstractReport. There is common functionality built on top of common objects. Isn't this the point of inheritance? I'm essentially saying that abstract class Shape has a getArea function and then I'm defining multiple types of Shapes (e.g. Rectangle and Circle) to work with...

  • Nested Classes and Static Methods

    I was perusing the Java Tutorials on Nested Classes and I came across this...
    [http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html|http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html]
    I was reading the documentation and I read a slightly confusing statement. I was hoping some further discussion could clarify the matter. The documentation on "Nested Classes" says (I highlighted the two statements, in bold, I am having trouble piecing together.)
    Static Nested Classes
    As with class methods and variables, a static nested class is associated with its outer class. And like static class methods, a static nested class cannot refer directly to instance variables or methods defined in its enclosing class ? it can use them only through an object reference.
    Note: A static nested class interacts with the instance members of its outer class (and other classes) just like any other top-level class. In effect, a static nested class is behaviorally a top-level class that has been nested in another top-level class for packaging convenience.
    So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?

    So this means a nested static inner class CANNOT refer to its own instanced variables, like a normal static method, but CAN refer to its outer class instanced variables?No, it means that a static nested class cannot refer to instance variables of its enclosing class. Example:public class Foo {
        int i;
        static class Bar {
            int j = i; // WRONG! Bar class is static context
    }~

  • Hidding java class field and methods

    Hi,
    I'm developing an API and I want to know if there's any way to hide all private class, field and methods when exploring the JAR from eclipse or another IDE. In [this capture|http://i8.photobucket.com/albums/a32/darkskimmer/Sinttulo-1-2.jpg] I can see "extra-information" like return type of private methods, etc. I want to keep this in secret...
    Cheers!
    P.S: I have to improve my english skills, I know... :)

    darkskimmer wrote:
    I'm developing an API and I want to know if there's any way to hide all private class, field and methods when exploring the JAR from eclipse or another IDE. Since the JVM has to be able to see them to access/execute them and and anything it can do you can do then you can't hide them.

  • Creation of a static class with private methods

    I'm new to java programming and am working on a project where I need to have a static class that does a postage calculation that must contain 2 private methods, one for first class and one for priority mail. I can't seem to figure out how to get the weight into the class to do the calculations or how to call the two private methods so that when one of my other classes calls on this class, it retrieves the correct postage. I've got all my other classes working correct and retrieving the information required. I need to use the weight from another class and return a "double". Help!!!
    Here's my code:
    * <p>Title: Order Control </p>
    * <p>Description: Order Control Calculator using methods and classes</p>
    * <p>Copyright: Copyright (c) 2002</p>
    * <p>Company: Info 250, sec 001, T/TH 0930</p>
    * @author Peggy Blake
    * @version 1.0, 10/29/02
    import javax.swing.*;
    public class ShippingCalculator
    static double firstClass, priorityMail;
    //how do I get my weight from another class into this method to use??? not sure I understand how it works.
    public static double ShippingCalculator(double weight)
    String responseFirstClass;
    double quantity, shippingCost;
    double totalFirstClass, firstClass, priorityMail, totalShipping;
    double priorityMail1 = 3.50d;//prioritymail fee up to 1 pound
    double priorityMail2 = 3.95d;//prioritymail fee up to 2 pounds
    double priorityMail3 = 5.20d;//prioritymail fee up to 3 pounds
    double priorityMail4 = 6.45d;//prioritymail fee up to 4 pounds
    double priorityMail5 = 7.70d;//prioritymail fee up to 5 pounds
    quantity = 0d;//ititialization of quantity
    // weight = 0d;//initialization of weight
    // shippingCost = 0d;
    //calculation of the number of items ordered..each item weights .75 ounces
    quantity = (weight/.75);
    if (quantity <= 30d)
    //add 1 ounce to quantities that weigh less than 30 ounces
    weight = (weight + 1);
    else
    //add 2 ounces to quantities that weigh more than 30 ounces
    weight = (weight + 2);
    if (weight > 80d)
    //message to orderclerk ..order over 5 lbs, cannot process
    JOptionPane.showMessageDialog(null, "Order exceeded 5 lbs, cannot process");
    //exit system, do not process anything else
    System.exit (0);
    else
    if (weight < 14d)
    //send message to customer: ship firstclass or priority, y or n
    responseFirstClass = JOptionPane.showInputDialog(null, "Ship first class? y or n?");
    if (responseFirstClass.equals("y"))
    //compute FirstClass shipping cost
    totalFirstClass = ((weight - 1) * .23d) + .34d;
    firstClass = totalFirstClass;
    else
    //compute PriorityMail cost for orders less than 14 ounces
    priorityMail = (priorityMail1);
    else
    if (weight <=16d)
    //compute totalshipping for orders up to 16 ounces
    priorityMail = (priorityMail1);
    else
    if (weight <=32d)
    //compute totalshipping for orders up to 32 ounces
    priorityMail = (priorityMail2);
    else
    if (weight <=48d)
    //compute totalshipping for orders up to 48 ounces
    priorityMail = (priorityMail3);
    else
    if (weight <= 64d)
    //compute totalshipping for orders up to 64 ounces
    priorityMail = (priorityMail4);
    else
    //compute totalshipping for orders up to 80 ounces
    priorityMail = (priorityMail5);
    priorityMail = 0d;
    firstClass = 0d;
    firstClassMail ();
    priorityMailCost ();
    //I think this is where I should be pulling the two methods below into my code, but can't figure out how to do it.
    shippingCost = priorityMail + firstClass;
    return (shippingCost);
    }//end method calculate shipping
    private static double firstClassMail()//method to get first class ship cost
    return (firstClass);
    }//end method firstclass shipping
    private static double priorityMailCost()//method to get priority mail cost
    return (priorityMail);
    }//end method priorityMail
    }//end class shipping calculator

    public class A {
    public String getXXX () {
    public class B {
    A a = new A();
    public void init () {
    a.getXXX();
    }

  • How to get inputted value in a RTE field on custom page and submit by REST call in 'Sharepoint hosted app'.

    Hi I am facing the three questions below.
    1. How to use default RTE in custom page in Sharepoint hosted app.
     I saw the article of Rich text Editor (ribbon based) in a webpart in SharePoint 2013 and tried it. But it did not work well. I guess it needs code-behind setting, however sharepoint hosted app does not support code-behind.
    Does anybody know how to do this?
    2. In above case, I placed the below code on custom page and tried to get the field's value when submit button was clicked.
    <SharePoint:InputFormTextBox ID="rftDefaultValue"
    RichText="true"
    RichTextMode="FullHtml" runat="server"
    TextMode="MultiLine" Rows="5">
    </SharePoint:InputFormTextBox>
    In debugger, the returned value was 'undefined'.
    var note = $('#hogehoge').val();
    Is it possible to get the RTE value? If yes, please let me know how to do this.
    3. I need to submit the RTE value using REST call.
    In this
    article in MSDN, the item creation sample treats single line text field. Does anybody know the sample for RTE?

    Hi,
    According to your description, you might want to use Rich Text Editor control in your SharePoint hosted app.
    First of all, I would suggest you post one question in one thread to make it easier to be discussed, which would also help you get a quick solution.
    Though we can add this control into a SharePoint hosted app, however, as we can’t add code behind for it, plus with the potential compatibility issues in different
    browsers, I would suggest you use other JavaScript Rich Text Editor plugins instead.
    Two JavaScript Rich Text Editor plugins for your reference:
    http://quilljs.com/
    http://nicedit.com/
    If you want to submit the value of Rich Text Editor control to a SharePoint list using REST call, since the content in the Multiple Line of Text column is wrapped
    with nested HTML tags, the similar requirement would also be applied to the content to be submitted.
    Here is a code snippet about how to update a Multiple Line of Text column for your reference:
    updateListItem(_spPageContextInfo.webAbsoluteUrl, "List018", 1);
    function updateListItem(siteUrl, listName, itemId)
    var itemType = GetItemTypeForListName(listName);
    var item = {
    "__metadata": { "type": itemType },
    "MultiTextEnhanced": "<div><a href='http://bing.com/'>Bing</a><br></p></div>",
    "Title": "123"
    $.ajax({
    url: siteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items(" + itemId + ")",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
    console.log(data);
    $.ajax({
    url: data.d.__metadata.uri,
    type: "POST",
    contentType: "application/json;odata=verbose",
    data: JSON.stringify(item),
    headers: {
    "Accept": "application/json;odata=verbose",
    "X-RequestDigest": $("#__REQUESTDIGEST").val(),
    "X-HTTP-Method": "MERGE",
    "If-Match": data.d.__metadata.etag
    success: function (data) {
    console.log(data);
    error: function (data) {
    console.log(data);
    error: function (data) {
    console.log(data);
    // Getting the item type for the list
    function GetItemTypeForListName(name)
    return"SP.Data." + name.charAt(0).toUpperCase() + name.slice(1) + "ListItem";
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
    contact [email protected]
    Patrick Liang
    TechNet Community Support

  • Thread safe logging class, using final and static

    Hi,
    I'm looking through a logging class (which writes entries to a text file and so on) written by someone else, and I'm trying to determine whether it's thread-safe...
    Essentially the class looks like this:
    public final class Logger {
    private static FileOutputStream fout;
    private static PrinterWriter pout;
    private static final long MaxLength = 100000;
    static {
    /* basically checks size of logfile, if bigger than 100k, then copy it as bak, and start again */
    public void write(String msg) {
    /* write entry into log file */
    public void writeWithTimeStamp(string msg) {
    /* write entry with time stamp into log file */
    Now, I could be wrong, but I don't think that the class is thread-safe is it? in order to be thread-safe, I would have to use synchronized before write() and writeWithTimeStamp(), right?
    My confusion arises from the use of the keyword "final" at the top of the class. This class isn't being inherited (or rather, there's no reason for the class not to be inheritable)... so what is it's purpose, if there is one?!
    And my other question concerns the static block. But I need to describe the current setup first: The Logger class is being use by a file server. File server basically sits there, accepts socket connections from the outside, and takes text files and output them into a local directory. When a new socket connection is created, a new thread is created. As it stands right now, each thread instantiates its own Logger object which seems weird! Bringing me to my question which was, if each thread instantiates its own Logger object, the static block is only ran ONCE, regardless of how many threads (and therefore Logger objects) are created, right??
    And wouldn't it be a better idea to simply create only ONE Logger object and pass it by reference to all newly created threads as they are needed so that all threads access the same and only Logger object? (and therefore utilize sychronization)
    Thanks!

    In JDK 1.4, there are already classes written that do all of that work. Check out the docs for the java.util.logging package. Specifically, check out FileHandler (which can rotate log files if they are greater than a specified size) and LogRecord (which is a standardized way to store logging entries). I believe the class is threadsafe, it doesn't say it isn't. Try it and see. If not, you can easily make a threadsafe wrapper for it (or any class for that matter).
    The online documentation is at:
    http://java.sun.com/j2se/1.4/docs/api/index.html
    If you are curious, the simplest way to make any class threadsafe, if you don't want to or are not able to modify the class code itself is to define another class that calls methods of the original class, but that is synchronized.
    Example:
        // NonThreadSafe.java
        public class NonThreadSafe {
            public NonThreadSafe (String s) {
                // Constructor
            public void SomeMethod (int param) {
                // Do some important stuff here...
            public int AnotherMethod (boolean param) {
                // Do some more important stuff here...
        // ThreadSafeWrapper.java
        public class ThreadSafeWrapper {
            protected NonThreadSafe nts;
            public ThreadSafeWrapper (String s) {
                nts = new NonThreadSafe(s);
            public synchronized void SomeMethod (int param) {
                nts.SomeMethod(param);
            public synchronized int AnotherMethod (boolean param) {
                return nts.AnotherMethod(param);
            public NonThreadSafe GetNonThreadSafe () {
                return nts;
        };Unfortunately, ThreadSafeWrapper isn't derived from NonThreadSafe, so you are somewhat limited in what you can do with it compared to what you could do with NonThreadSafe. AFAIK, you can't override unsynchronized methods with synchronized ones.
    Another thing you could do is just write a method that writes to your logging class, and synchronize just that method. For example:
        // ThreadSafeLogger.java
        public class ThreadSafeLogger {
            public static synchronized void LogMessage (MyLogger log, String msg) {
                log.writeString(msg);
        // In another thread, far, far away:
            ThreadSafeLogger.LogMessage(theLog, "Blah");
            ...Hope that helps.
    Jason Cipriani
    [email protected]
    [email protected]

  • Addition of custom tab and fields in cProject

    Hello Experts,
    I need to add custom tab and fields in cProject project definition level(type DPO).
    As it is given in IMG help, there are two ways of doing this.
    1) Addition of data in CI_DPR_PROJECT and Creating the field groups and including these fields in the field groups.
    2) Creating the custom tab and assigning the webDynpro component to it.
    I tried the first method. Here I am able to see the field group as the tab in cProjects but the fields included in CI_DPR_PROJECT are not appearing.
    Please let me know how I can see the fields which are added to CI include.
    Also,
    For the second method what is the meaning of implementing the WebDynpro interface DPR_CUST_EXT_INTF ?
    I appreciate if anyone explains step by step procedure for this.
    Thanks in advance.
    Regards
    Maddy

    hi Madhu,
    By creating a custom tab and adding field you can do that.
    Pls. follw the steps as below:
    1)Enhance Data base table:
    Follow the path:
    Spro ->Collaboration Project ->Global Enhancement to Project elements ->Enhance Database table
    You will get details about Object category, its Entity table and Structure with Customer Include/APPEND Structure
    Then go to Se11 and make changes as mentioned below:
    Add the fields required on cProjects Screen in table DPR_PROJECT in the Include "CI_DPR_PROJECT"
    2)Run Program DPR_CUST_FLDS_IN_FC_MAP and pass structure : DPR_TS_PROJECT_EXTENDED_ATTR
    Run Program DPR_CUST_FLDS_IN_FC_MAP in transaction code SE38 and execute it and in Structure w. Customer Include field, pass structure: DPR_TS_PROJECT_EXTENDED_ATTR, this will generate transport request
    3)Set up field control.
    Copy std. field control and create new.
    Path:Spro ->Collaboration Project ->Global Enhancement to Project elements ->Set up field control
    4)Create field group
    Path: Spro ->Collaboration Project ->Global Enhancement to Project elements ->Set up field control
    Define group to your field here for your field control.
    5)Define Field groups for Customer Fields
    Path: Spro ->Collaboration Project ->Global Enhancement to Project elements -> Define Field groups for Customer Fields
    Make entry here. Name of group is Name of tab page in cProjects front end
    Define your customer fields for field group
    6)Assign field control to your Project Type:
    Path : Spro ->Collaboration Project ->Structure ->Define Project type
    Assign custom defined field control to the project type in Field contol field at the bottom.
    With this seetings you should be able to see your custom defined fields in custom defined tab page.
    Regards,
    Niraj

Maybe you are looking for

  • Problems with Pages 5 docs converting to Word docs

    It seems with the new upgrade on my MacBook Air, I have a glitch. Now when I convert a Pages doc to Word, the page breaks get removed and the doc turns into a sea. Also, I sent this new Word doc to my Kindle to upload into ebook form (never had a pro

  • BI Conceptual Questions

    Hi , I have few simple query... Q1.Client manager wants notification via e-mail with a single file attached that shows sales variance greater than 15% by customer by region.Out of following four,which options I can use and why....? 1)Independent HTML

  • While dragging and dropping text on Mail sometimes is copied instead of moved

    When composing a message under Mail it happens that a word needs to be cut from a place and paste somewhere else in the body. Instead of cutting&pasting most text editors allow the user to drag the selected word (or consecutive words) and drop them a

  • Problem in background run

    hi experts, I want to run program everyday 17.00 hrs. i have set the date as system date. When i schedule the background job,system always taking as job created date only. how to solve this issue. thanks K.Bhuvaneswaran

  • Can I Change SEARCH to default as LIST view rather than GROUPS view?

    Can I Change SEARCH to default as LIST view rather than GROUPS view? I always end up doing a command+2 and if I can default this it would be better. THANKS