Use of protected constructors.

Hi all,
I understand the uses of making a constructor private or package-private, I was wondering what could be the possible uses of making a constrcutor protected.
From what I understand a constructor could be made protected for immutable objects with static factory methods where the subclass in the other package is TRUSTED not to voilate the superclass's invariants but is only expected to better the implementation or add more attributes.
Another reason what I can think of is a Singleton, where again the subclasss in the other package is TRUSTED not violate the singleton semantics but add additional services/behaviour.
Am I right in what I am thinking? Are there more benefits?
Thank you very much for your time,
Amnesiac.

If a class is designed for subclassing then it may have protected constructors different from its public constructors to allow the subclasses a bit more control about initializing thier superclass. In these cases the public constructors often call the protected ones with some default values that make sense for the base class.
Not a common occurrence though.
matfud

Similar Messages

  • Protected constructor

    What does a protected constructor for a class mean?

    es5f2000 wrote:
    el3orian wrote:
    it means that u can use that constructor to initialize that class only inside that class or in any of its subclassesFalse.To elaborate, other classes within the same package can also access a protected constructor (covered in the tutorial linked in reply #1).
    ~

  • How to find a lost BlackBerry 10 smartphone using BlackBerry Protect

    Posted originally on the Inside BlackBerry Help Blog
    It’s a scenario no one wants to encounter but here’s a quick overview how you can help locate your BlackBerry 10 smartphone using BlackBerry Protect if you can’t find it.
    Tip: Using a BlackBerry OS device? Check out this post for help locating your device using BlackBerry Protect.
    Step 1 – Enable BlackBerry Protect and turn on Location Services
    To locate your smartphone you must enable BlackBerry Protect and turn on Location Services.
    After you turn on Location Services, your smartphone only sends its location information when you request it through the BlackBerry Protect website, or when your battery power is low.
    Swipe down from the top of the screen
    Tap  Settings > BlackBerry Protect
    Set the BlackBerry Protect switch to On
    Tap Location Services
    Set the Location Services switch to On
    Tap  Back to save your change
    Step 2 – Log in to the BlackBerry Protect website
    After you enable BlackBerry Protect and turn on Location Services, complete the following steps to view the location of your smartphone on a map.
    Log in to the BlackBerry Protect website located at http://protect.blackberry.com
    Click View Location
    BlackBerry Protect will attempt to locate your smartphone
    If your smartphone can be located, a map appears similar to the following showing the approximate location:
    If you still can’t find your smartphone at the reported location, use the Play Sound option within the BlackBerry Protect website. This option makes your smartphone ring loudly for one minute as well as activating the Loud profile.
    Help! BlackBerry Protect can’t locate my smartphone!
    To locate your device it must be turned on and connected to the wireless network.
    Because BlackBerry Protect also uses GPS, you may not locate your smartphone if it is inside a building, underground, or otherwise blocked from receiving a satellite signal.
    Did someone help you? Click Like! Did a post solve your issue? Click Accept as Solution!
    Follow me on Twitter or Google+ and subscribe to the Inside BlackBerry Help Blog

    TyW....... Great post...!   

  • Untitled File Already in Use or Protected

    Hi everyone,
    from the starting point when I click on the text editor of Apple Work, a box appears; it says: "untitled file already in use or protected; open a copy?", but I just opened AppleWorks and not one AW file was opened or protected.
    I have a .doc file in the trash, and every time I try to empty the trash, another similar box opens (can't empty the trash because the .doc file is still in use - Stop - Continue-). Useless to say that it's not in use at all.
    Help would be SO appreciated...
    Thanks.

    Unless your new account has the same user name, it is almost certainly a permissions issue. Select this templates folder in the Finder, Get Info (File > Get Info, ⌘ i or through the contextual menu), click the triangle next to Details under Ownership & Permissions & change the permissions on the folder to Read & Write for all users &, lastly, click the button to apply to enclosed items. Hopefully, this will reset them. I have found that sometimes the change isn't applied to items in folders inside the first folder, so you may have to do this in several steps.
    Peggy

  • Why does the new version of Firefox not integrate with Norton 360 Identity Safe. Problem for me because I use Norton 360 Identity Safe to manage my passwords and make it more difficult to use password protected website without that add-in.

    I use Norton 360 Identity Safe to manage my passwords and it makes it difficult to use password protected website without that add-in.

    Norton release Firefox 8 compatibility already, instruction are here
    * http://community.norton.com/t5/Norton-360/Firefox-8-Support-for-Norton-Toolbar/td-p/581640

  • What is use of protect filter in OBIEE

    Hi guys,
    Could you please let me know what is use of Protect filter in OBIEE ?
    Regards,
    sk

    "Protect filter" basically "hard-codes" a filter so that it won't be overwritten.
    Say you want to always filter a column for "X," but also want to include a value from a dashboard prompt. So you write the following:
    table.column = 'X'
    or
    table.column "Is prompted"
    The user chooses the value "Y" from the prompt and the filters now look like this:
    table.column = 'Y'
    or
    table.column = 'Y'
    Gone is the "X" value because it was overwritten by the prompt. If you protect the top filter, you will get:
    table.column = 'X'
    or
    table.column = 'Y'

  • Recovering automatica​lly deleted txt messages using BB Protect

    Hi 
    Just realised that my trusty Bold 9700 ( V6 software) has been automatically deleting txts older than 30 days, after searching on here I have changed the setting to "keep for ever" but need to recover one that is about 50 days old.  I back up loads of stuff inc texts roughly weekly using Blackberry Protect  - i have never used recovery function before but hoping my 50 day old text is recoverable using that.
     Been using Protect for months and months but only 4 archives visible under the My Data tab ( roughly from 1 week ago, 2 weeks ago, 3 weeks ago, 4 weeks ago) . Oldest archive is about  26 days ago so I'm assuming that that will have every txt from about day 26  to day 56.  Is that right ?
    If I recover backup from this 26 day archive will that over write more recent texts on my phone ?  or add them to existing texts?
    Nervous about doing a back-up now as it seems that Protect only keeps 4 most recent backups  ( i.e new backup might overrwrite oldest archive - the one I probably need!).
    Any help appreciated.
    Me not old   

    Restoring data using BlackBerry Protect merges the backup information with the information already present on the smartphone. See KB25063 for information on how to restore data to the BlackBerry smartphone using BlackBerry Protect.
    Click here to Backup the data on your BlackBerry Device! It's important, and FREE!
    Click "Accept as Solution" if your problem is solved. To give thanks, click thumbs up
    Click to search the Knowledge Base at BTSC and click to Read The Fabulous Manuals
    BESAdmin's, please make a signature with your BES environment info.
    SIM Free BlackBerry Unlocking FAQ
    Follow me on Twitter @knottyrope
    Want to thank me? Buy my KnottyRope App here
    BES 12 and BES 5.0.4 with Exchange 2010 and SQL 2012 Hyper V

  • Do I have to use passcode protect with iOS 7?

    Do I have to use passcode protect with iOS 7?

    Undo password protection
    Settings>General>Passcode Lock>Off

  • Can we use an overloaded constructor of a Java Bean with Session Tracking

    Hi Friends,
    If any one can solve my query.... It would be helpful.
    Query:
    I have a Java Bean with an overloaded constructor in it. I want to use the overloaded constructor in my JSP.
    1. One way of doing that is to use it directly in the "Scriptlets" (<% %>). But then I am not sure of the way to do session tracking. I think I can use the implicit objects like "session", "request" etc. but not sure of the approach or of the implementation method.
    2. Another way is through the directive <jsp: useBean>. But I cannot call an overloaded constructor with <jsp: useBean>. The only alternative way is to use the directive <jsp: useBean> where I have to write getter and setter methods in the Java Bean and use the <jsp: setProperty> and <jsp: getProperty> standard actions. Then with this approach I cannot use the overloaded constructor.
    Can any one suggest me the best approach to solve this problem ?
    Thanks and Regards,
    Gaive.

    My first reaction is that you can refactor your overloaded constructor into an init(arguments...) method. Instead of overloaded constructor, you can call that init method. This is the ideal solution if possible.
    As to the two choices you listed:
    1. This is OK, I believe. You can use scriplet to define the bean and put it into session scope of the pageContext. I am not sure exactly what you meant by session tracking; whatever you meant, it should be doable using HttpSessionAttributeListener and/or HttpSessionBindingListener.
    2. Agreed. There is no way that <jsp:useBean> can call a constructor that has non-empty arguments.
    Please tell me how it works for you.

  • How to use a protected attribute of class cl_gui_alv_grid

    Hello all,
           i have a scenario where i need to use the attribute 'm_appl_events' which is protected attribute. in need to add this event type into my events and add this to registered events.
        when i tried to use this with refrence to class i defined, it showing an error message 'access to protected attribute m_appl_events is not allowed. i already inherieted the cl_gui_alv_grid class into my class
         can any one please tell me how exactly could i use the protected attribute.
    Thanks,
    raju N

    Hi Krishna,
    Protected method or attrubute can be accessed through Inheritence or Friends functionality. So you can inheritence easily in you case . so that you can access the variable in the Inherited sub class only. So you can write 2 methods ie GET or SET ing the value of your protected method.
    I think this informatio may help you.
    Best Regards,
    Vijay

  • Creating a object of Protected Constructor ?

    This code is working fine for me
    <defvar name='dateFormat'>
    <new class='java.text.SimpleDateFormat'>
    <s>dd-MMM-yyyy</s>
    </new>
    </defvar>
    but not this below one
    <defvar name='xmas'>
    <new class='java.util.Calendar'/>
    </defvar>
    when i checked java doc it says
    protected Calendar()
    so how can i create or access a protected constructor in java like above one.
    Thanks in advance.

    <invoke name='getInstance' class='java.util.Calendar'/>
    Dana Reed
    AegisUSA
    Denver, Co
    [email protected]
    "No Hiring best-in-class identity experts"
    Inquire via email.

  • Example using command protect & endprotect

    hii gem's
    im unable to find the difference when using protect...endprotect
    without tht bcoz im getting same output
    ex:
    /: protect
    PH  'THIS IS TEST'
    PH  'THIS IS TEST'
    /: NEW-PAGE
    PH 'THIS IS TEST'
    ENDPROTECT
    please give a example using command protect & endprotect
    THANK U
    REWARDS FOR GUD REPLY
    REGARDS
    JAIPAL

    Hi Jaipal,
    It is mainly used to prevent the page break
    menas whatever lines you wrote between these protect and endprotect they are always printed in a single page only and they won't split into two pages though there is no full space
    go to SE71 see any scripts pagewindows
    you will find a lot of examples
    /E           TOTAL_AMOUNT
    /:           PROTECT
    UL           &ULINE(71)&
    TO                                                                                  
    TO           ,,Total net value excl. tax &EKKO-WAERS&,,
                                        &KOMK- FKWRT&
    /:           IF &SUM-EURO-PRICE& NE '                0,00'
    /           ,,                          EURO,,&SUM-EURO-PRICE&
    /:           ENDIF
    /:           ENDPROTECT
    Reward points for useful Answers
    Regards
    Anji

  • Do you recommend using a protective shield for the iPad2 screen

    Do you recommend using a protective shield for the iPad2 screen

    This is a very subjective issue. Do I recommend it? .... Not necessarily. Do I use one?..  Yes I do. I use the ZAGG InvisibleShield on the screen. I love it because not only does it protect the screen from scratches - it is very easy to clean. While I love the look of the unprotected iPad screen, I hated the fingerprints.

  • Hi I am searching for a app which i can use to protect games or other apps from my childs. not to protect all only a few

    hi im searchingg for an app which i can use to protect games or other apps from my childs. not to protect all only a few

    Sorry, but you will not find any such app.  The iOS itself is set up such that 3rd parth apps can have almost no interaction with any other app (exceptions being the ability of some to read data from some of the OS included feautures, like Maps reading location information from iOS location services).  So there is no way to design an app that would interfere with or restrict how another app works - the iOS simply precludes that.

  • Abstract Classes vs. Protected Constructors

    I thought I'd like to pose a more language philosophical question. (I sure miss Advanced Language Topics)
    Question: suppose one has a class which must be subclassed solely for runtime type identification (RTTI), i.e. the class is fully implemented, and even all of its methods are final.
    It seems to me the JLS offers two options:
    &nbsp&nbsp&nbsp&nbsp 1. Make the class abstract. (even though it has no abstract methods)
    &nbsp&nbsp&nbsp&nbsp 2. Make the constructor of the class protected.
    These approaches seem equivalent, however I am curious if anyone has reasons to prefer one approach over another.
    I suppose the exceptionally paranoid might even advocate using both! :-)
    Thanks for your participation, or at least reading.
    [url https://cajo.dev.java.net/index.html]-John
    PS There are Dukes available; if you have yet another interesting approach!

    how about:class Measure {
         public static final int FLUID_MEASURE     = 1;
         public static final int VOLUME_MEASURE     = 2;
          * Only way to get these things.
         public Measure createNew(int type){
              switch(type){
                   case FLUID_MEASURE:
                        return new FluidMeasure();
                   default:
                        throw new IllegalArgumentException("");
          * No instances or outside subclassing
          * allowed.
         private Measure(){}
          * Private so it can't be extended.
         private class FluidMeasure extends Measure { }
    } it directly prevents anyone from doing anything with the class ... you
    are in complete control of what subclasses are allowed ... :)

Maybe you are looking for

  • Text not viewable in some browsers

    I made a Flash site with text and graphics, and have been told by some of my customers that only the graphic appears on the page. The site is www.simplypilatesnashville.com. Is this just a browser, Flash player issue? Thanks.

  • Aironet 1140 FLEXCONNECT External Web Authentication and Apple Devices

    Hi! I'm having an issue with this Access Point. I've configured this access point with WLC in mode FlexConnect with web authentication. It's all right, i'm connecting with my PC in wireless, i open my web browser in windows, then the Access Point red

  • Link between in SRM and R3

    Hi,       Where vendor number created in SRM get stored and how do I found link between vendor number in SRM and it's relevent vendor number in R3 ?

  • Pacman fails. gcc-uclibc: requires kernel-headers- What's this???

    After my last update a few weeks ago, I always get this.  I've updated kernel, pacman, and initscripts manually, and messed with pacman.conf for days. Read countless forums posts, googled for hours, tried many "solutions" and can't figure this out. 

  • To find Infoobject on which a variable is created

    Hi all, How can we find the infoobject on which a variable is created ? I would like to know the properties of the variable. Any pointers reg the same would be highly appreciated. Regards Snehith.