Private variables make it hard to extend TLF classes

I am making a class that extends EditManager and I wanted to access pendingInsert but it is a private var, so I can not.  Is there a way around this?  Are private vars much better for memory, why not use protected? 

It would be useful if we could get a public getter for the private _numCharsAdded variable in the PasteOperation class.  It is difficult to derive that value by other means and it seems that a public getter there would not have any implications.
The _tScrapUnderSelection private variable in PasteOperation would be another candidate.  When doing post-processing of the paste operation via FLOW_OPERATION_END, it would be useful to be able to determine any elements that were modified or removed as a result of the paste.  Currently we have to handle FLOW_OPERATION_BEGIN and create our own text scrap for the selection and keep that around for our post-paste processing.  Would be nice if we didn't have to create that second text scrap.
In general, where there is information held privately inside of operations that could be useful for those of us who pre/post process operations, it would be good to expose information that we can use to understand the changes the operations are making.  Use of tlf_internal would be acceptable for us also.  A few more examples are _origID in ApplyElementIDOperation and _origStyleName in ApplyElementStyleNameOperation.
Thanks,
Brent

Similar Messages

  • [svn:bz-trunk] 21285: Need to change _parent, privateCall and instance properties from private to protected in order to extend this class for another project

    Revision: 21285
    Revision: 21285
    Author:   [email protected]
    Date:     2011-05-20 07:53:23 -0700 (Fri, 20 May 2011)
    Log Message:
    Need to change _parent, privateCall and instance properties from private to protected in order to extend this class for another project
    Modified Paths:
        blazeds/trunk/apps/ds-console/console/ConsoleManager.as

    Revision: 21285
    Revision: 21285
    Author:   [email protected]
    Date:     2011-05-20 07:53:23 -0700 (Fri, 20 May 2011)
    Log Message:
    Need to change _parent, privateCall and instance properties from private to protected in order to extend this class for another project
    Modified Paths:
        blazeds/trunk/apps/ds-console/console/ConsoleManager.as

  • Can one obj access a private variable of another obj of the same class

    Can one object access a private variable of another object of the same class?
    If so, how?

    Declaring variable private means you can not access this variable outside class
    But other objects of same class can access it. Because each object have separate copy of variable and may have diff. contents for same variable.

  • Encapsulation hide private variable

    As below code showing that you cannot directly access the private variable as i understood, Pls guide.
    public class EncapsulationDemo{
       private int ssn;
       private String empName;
       private int empAge;
       //Getter and Setter methods
       public int getEmpSSN(){
       return ssn;
       public String getEmpName(){
       return empName;
       public int getEmpAge(){
       return empAge;
       public void setEmpAge(int newValue){
      empAge = newValue;
       public void setEmpName(String newValue){
      empName = newValue;
       public void setEmpSSN(int newValue){
      ssn = newValue;
    public class EncapsTest{
       public static void main(String args[]){
       EncapsulationDemo obj = new EncapsulationDemo();
      obj.setEmpName("Mario");
      obj.setEmpAge(32);
      obj.setEmpSSN(112233);
       System.out.println("Employee Name: " + obj.getEmpName());
       System.out.println("Employee SSN: " + obj.getEmpSSN());
       System.out.println("Employee Age: " + obj.getEmpAge());

    As below code showing that you cannot directly access the private variable as i understood,
    That code shows NO such thing.
    Tell us what line you think you are 'directly' acessing a private variable. Looks like you are using accessors for ALL accesses to me.
    See The Java Tutorials trail 'What Is an Object'. It discusses encapsulation.
    What Is an Object? (The Java™ Tutorials > Learning the Java Language > Object-Oriented Programming Co…
    Hiding internal state and requiring all interaction to be performed through an object's methods is known as data encapsulation — a fundamental principle of object-oriented programming.

  • Extending Private Variables

    Can someone explain to me how to extend a private variable. I think I am looking at it all wrong.
    This is what I'm thinking:
    public abstract class SuperClass{
    private int x = 2;
    private int y = 3;
    public class SubClass extends SuperClass{
    public int addTest{return x + y;}
    I think the addTest should compile and return 5. (Instead it doesn't compile). I realize that a private variable cannot be accessed outside of its own class. But SubClass is extending the SuperClass variables. So shouldn't x and y be private to SubClass now? Otherwise, it seems like I have to redeclare x and y. This would be losing the benefits of the object oriented write once theory.
    Any help is greatly appreciated.
    Thanks,
    Chris

    One correction above: public int addTest(){return x +
    y;}.
    The class still won't compile though (getting the
    message: x has private access in SuperClass).
    My questions above remain the same.
    Sorry about that.Subclasses do not inherit the private members of the superclass. If you want to expose the superclass's members to only the subclass the member must be declared as protected. Here's a link to Sun's Java tutorial that explains what a subclass can inherit from the superclass:
    http://java.sun.com/docs/books/tutorial/java/javaOO/subclass.html

  • Change public variables that are used in another class to private variables

    Hi
    I have public variables in one class and I am also using them in another class the only thing is all my variables are supposed to be private. When I change then to private then I cannot use them in the other class. Please someone help me.
    Thanks
    D

    First way - make variables protected an you can access them from any class within package or from any class that extends class with variables.
    Second - make variables private and create public get/set methods for that variables for accessing they from any other class/package.(That's preferable way).
    I have public variables in one class and I am also
    using them in another class the only thing is all my
    variables are supposed to be private. When I change
    then to private then I cannot use them in the other
    class. Please someone help me.

  • Enforce setting private variable in subclass with abstract method

    Hi,
    Is this something that is common usage/practice?:
    public abstract class Base {
        private int importantPrivateVariable = setImportantPrivateVariable();
        protected abstract int setImportantPrivateVariable();
    }I would like to enforce the extender of the class to set a private variable, but as there is no abstract variable in java, I can only use a method for it.
    Thanks,
    lemonboston
    Edit: the variable could be protected as well, I suppose this is not important here, but correct me if I am wrong

    lemonboston wrote:
    Hi,
    Is this something that is common usage/practice?:I don't think that's so common, but that's code easily understandable. However there are several problems with this approach:
    public abstract class Base {
    private int importantPrivateVariable = setImportantPrivateVariable();
    protected abstract int setImportantPrivateVariable();
    }I would like to enforce the extender of the class to set a private variableThat's no what your code implements: your base class forces the subclasses to return an int value, and the Base class uses that value to assign it to the variable.
    Therefore the method should be called get<Something> (e.g. <TT>getInitialValueOfImportantVariable()</TT>+ to have a naming consistent with its signature (it returns a value, whereas a regular setter method should declare a void return type: <TT>protected abstract void setImportantPrivateVariable(int someValue);</TT>).
    Edit: the variable could be protected as well, I suppose this is not important here,Well, yes, this is "important" - at least, there a noticeable difference: the variable being private, the base class is free to handle it as it sees fit (e.g., assign the value at construction time and never modify it afterwards). If the variable was protected, the subclass could modify in ways and at times not known by the base class.
    but correct me if I am wrongThere's a trap in this construct: the method is called in the variable initializer, that is, behind the scenes, approximately during the execution of the Base class constructor, so before the subclass constructor. So, you are calling a method on an object that is not fully initialized (e.g. some of its attributes may still be <TT>null</TT> at this stage). There is a rule that discourages such situations, that goes something like "don't call non-private and non-final methods from a constructor".
    To avoid this trap, two options:
    - require an int argument in the Base class's constructor , as was suggested above
    - don't get and set the value of the important variable in the initializer or constructor code, but from a special method in the base class instead:
    public abstract class Base {
        private int importantPrivateVariable; // default value is zero
    // or alternatively:
    //    private int importantPrivateVariable = ...; // Some default value
        protected abstract int getImportantPrivateVariable();
        public void initializeImportantPrivateVariable() {
            importantPrivateVariable = getImportantPrivateVariable();
    }That construct is a degenerate form of a common design pattern known under the name of Template Method (where a base class method calls generally several subclass methods in a specified order and with a specified chaining, leaving it to the subclass to implement the details of the methods).
    The drawback is that the client code (the one that uses the Base instance) has to know when to call that initialization method, whereas the constructor-based initialization lets the client code free to not care at all.
    Much luck,
    J.

  • Multithread & private variables ?

    Hi,
    I would like to know if we can have private variables when we have multiple threads from the same class : in fact even if i declare a variable private when it is changed it is for all threads together, and for the future thread too : how can this be done please ???

    Hi !
    I'm sorry but really it doesn't work : i'm calling this servlet many times using get and st is everywhere set to carine...then I'm calling the post method that set up st to canard in all threads...but if i call a get again then st is set to carine again and everywhere : that means it is not private variables for each threads, I'm sorry but really I would like to know to do that properly....what's wrong ????
    Thank you for your help
    package servlettest;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class carine
        extends HttpServlet {
      private static class ThreadState {
        public String owner;
      private static ThreadLocal state = new ThreadLocal() {
        protected Object initialValue() {
          return new ThreadState();
      ThreadState st;
      public void init() throws ServletException {
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws
          ServletException, IOException {
        st = (ThreadState) state.get();
        st.owner = "carine";
        synchronized (this) {
          while (true) {
            System.out.println("st contains : " +  st.owner);
            try {
              this.wait(2000);
            catch (InterruptedException ex) {
      public void doPost(HttpServletRequest request, HttpServletResponse response) throws
          ServletException, IOException {
        System.out.println(st.owner);
        st.owner = "canard";
    }

  • About private variables

    Is there any way of accessing Private variables of a class into another class?

    The whole point of "private" is to make the variables private to the class. Your only sensible option is to use the "bean" standard, with setXXX() and getXXX() or isXXX(). For example:
    public class ABC {
        private boolean myLogic = false;
        private String myString = null;
        public boolean isMyLogic() {
            return myLogic;
        public void setMyLogic(boolean newMyLogic) {
            myLogic = newMyLogic;
        public String getMyString() {
            return myString;
        public void setMyString(String newMyString) {
            myString = newMyString;
    }Or, if side-effects are not a problem, just make the variables public.
    You may find the following links useful.
    http://java.sun.com/docs/books/tutorial/javabeans/index.html
    http://java.sun.com/products/javabeans/docs/spec.html
    Good luck!

  • Why private variables, while still can be accessed by accessor methods

    Agreed it is well defined way of encapsualtion. But i wonder how it works differently. can any one explain . We declare a varibale as private which can be accessed by accessor (set/get) methods which are usually public. so why dont we say vairbkles itself as Private ??
    Pls explain

    Not only that, but imagine the case where you have an api method, getTotal(). Your first iteratation you have something like:
    double gross;
    double net;
    double commission;
    so to get the total you may want gross - commission = net. Thus your method may look like:
    public double getTotal()
    return gross - commission;
    But later on, iteration 2 or so, you find out you need to account for taxes, so now you don't want to break the code, the result should be the same, the NET total. However, you now need to account for taxes:
    public double getTotal()
    return (gross - commission) + tax;
    Without breaking any code and all while maintaining the actual API definition, you have made a public accessor method provide more functionality. All code using the getTotal() method wont break nor has to be recompiled and even better it now takes into account tax.
    Now, there is one "sticky" issue in the above. Because the getTotal() makes direct use of "private" variables, you may not get the "right" tax. In other words, what if there is state and local tax that need to be added? You may have two variables:
    double localTax,stateTax;
    The problem is, do you want your method like this:
    public double getTotal()
    return (gross - commission) + localTax + stateTax;
    Or would it look (and possibly account for future updates) better like so:
    return (gross - commission) + getTax();
    The thing is, what if later on you have additional tax to handle? Sure, you can simply add it to the end, adding it, what ever. But by making a "helper" method of getTax(), you might have on iteration 2:
    private double getTax()
    return localTax + stateTax;
    and in iteration three, you may have:
    private double getTax()
    return localTax + stateTax + salesTax;
    Now, unless you are calling code in an intensive performance needy loop, making a couple of helper method calls won't hurt performance at all, and it will greatly enhance your code quality because you can easily change the implementation of the method(s) used, without affecting the API.

  • Private Variables

    What is the use in declaring a variable as private . Because if the user has to modify the variable we have to provide the user with get and set methods .
    He will declare an Object of that class and calls set /get methods. Instead we could have declared that variable as public and allow him to change directly?Is it something to do with "DataHiding" . If so how?

    What is the use in declaring a variable as private .
    Because if the user has to modify the variable we
    have to provide the user with get and set methods .Users don't modify variables. Code does. Often times good design dictates that no code outside the declaring class should be able to directly access a variable. So we make it private. Google for encapsulation or data hiding.
    He will declare an Object of that class and calls set
    /get methods. Instead we could have declared that
    variable as public and allow him to change
    directly?Is it something to do with "DataHiding" . If
    so how?Googlel for "why get and set are evil" or something like that. The author claims that get and set methods are no better than simply making the variables public. His comments are a bit extreme, but there's some truth to what he says.
    If you just blindly add get/set for every variable, then, yes, there's no point in making them private. However, you can do things with public methods on private variables that you can't do with public variables--change the underlying implementation, do validation of set values, compute values on the fly for get values. Get/set don't always have to simply be this.x = x or return x.

  • How can I make a table cell extend beyond the page?  The text disappears when the cell becomes larger than the page.

    How can I make a table cell extend beyond a page?  The text disappears when the cell becomes bigger than the page.  I want the table to continue to the next page.

    As a student, you might be able to get Office for Mac from the college bookstore at a substantial discount. Otherwise, I think your best option for documents that need to be shared with Office users is to get one of the free Office clones such as LibreOffice.

  • Accessing a private variable from a public method of the same class

    can anyone please tell me how to access a private variable, declared in a private method from a public method of the same class?
    here is the code, i'm trying to get the variable int[][][] grids.
    public static int[][] generateS(boolean[][] constraints)
      private static int[][][] sudokuGrids()
        int[][][] grids; // array of arrays!
        grids = new int[][][]
        {

    Are you sure that you want to have everything static here? You're possibly throwing away all the object-oriented goodness that java has to offer.
    Anyway, it seems to me that you can't get to that variable because it is buried within a method -- think scoping rules. I think that if you want to get at that variable your program design may be under the weather and may benefit from a significant refactoring in an OOP-manner.
    If you need more specific help, then ask away, but give us more information please about what you are trying to accomplish here and how you want to do this. Good luck.
    Pete
    Edited by: petes1234 on Nov 16, 2007 7:51 PM

  • Dam, did you know that ppl make things harder then they should be

    As I look here and other places I see that people make things harder then what they need tobe.I see people fearing fear when it comes to programming.They are so worried if they are going to make it or if they will pass this test or that test,well I got one thing to say and that is relax and just chill.Look at it this way it will if it will it won't if it won't.The point is enjoy what you do and live life that way,if you dont enjoy programming stop now.
    Just a thought from a hobbies

    And you should be using C instead of Java, right? :)
    Well I would not go that far cause that would be
    comparing languages then and I know all languages have
    there good points and bad points.Know one can really
    say what language is better cause it all depends on
    what you are trying to acomplish/do.But with that said
    what the hell ,yeah you should be using C instead of
    java if you are just starting to learn how to
    program.:-p So why not Pascal?

  • Not able to pass values to variables in extended Tree class

    Hi,
    I have a as class that extends from Tree, additionally this
    custom class defines
    new class level variables as follows:
    public class MyTree extends Tree {
    public var arrayColl:ArrayCollection;
    and i call this tree from mxml as follows:
    <customTree:MyTree
    arrayColl={list}
    xmlns:customTree="../../.*"/>
    Though my 'list' collections is not null, when i place an
    alert in the constructor of extended tree class
    it shows as null.
    Please advice.
    Thanks,
    Lucky

    below is the canvas:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
    import mx.collections.IViewCursor;
    import mx.collections.ArrayCollection;
    import com.citi.ascript.TreeData;
    import mx.controls.Alert;
    import com.citi.ascript.CitiTree;
    public var availableTreeDataColl:ArrayCollection;
    public var selectedTreeDataColl:ArrayCollection;
    public var treeData:TreeData;
    public var srcTree:CitiTree;
    public var availableTreeDataArray:Array = [{a:1},
    {b:2},
    {c:3}
    public function formTreeData():void {
    var tempColl:ArrayCollection = new
    ArrayCollection(availableTreeDataArray);
    availableTreeDataColl = new ArrayCollection();
    for (var i:int=0; i<tempColl.length; i++) {
    var tempTreeData:Object = tempColl
    treeData = new TreeData();
    treeData.a = tempTreeData.a;
    treeData.b = tempTreeData.b;
    treeData.c = tempTreeData.c;
    availableTreeDataColl.addItem(treeData);
    ]]>
    </mx:Script>
    <mx:VBox>
    <mx:Label text="Drag &amp; Drop the analysis sections
    that you would like to include in the report" width="450"
    height="20"/>
    <mx:HBox id="treeContainer"
    creationComplete="formTreeData();">
    <customTree:MyTree treeList={availableTreeDataColl} //
    here collection becomes null.
    </customTree:MyTree>
    </mx:HBox>
    </mx:VBox>
    </mx:Canvas>
    The collection of TreeData is iterated in the customTree to
    form xml which will act as dataprovider for tree.
    and this canvas is added as a child for a panel in my main
    application.
    Hope this gives an idea.
    Thanks,
    Lucky

Maybe you are looking for

  • How to Fix"Disk Utility has "lost connection" with Disk management tool

    Brian Z posted a work around for this problem on 1/2006 but the link no longer works. "this thread does not exist anymore". Please repost the solution, I have a couple of macs that are suffering from this problem.

  • Using resolve with toSpecifier() output for quick image previews

    Hi there, I am building an image preview service for in design documents in which a user uploads in design file, we extract custom fields, and display a GUI for the user to enter in custom field values to generate a preview. One of the features of th

  • Puzzled about fonts

    In a listing of these fonts one is white and not orange like the others. When I click (high light) on the orange fonts they get an orange dot. When I click (high light) on the white font the orange dot does not appear. All the fonts display perfect o

  • GPS time format

    Hi.. I am using NAVILI>CK GPS for our work related to Laser radar data aquisition. Through the simple code attached, I can read the time stamp in the way 12:23:45 (say UTC, hh:mm:ss). But I want to have the time stamp as 12:23:45.7653 (see change in

  • Flash player is not recognized even though we have the current version

    upon clicking on a youtube url we get an error message stating that we need to install the current version of flash in order to play the url. We already have that install and when cut and pasting it into IE it works just fine.