Inheritance, interface, urg, sorry...

(this question stems from http://forum.java.sun.com/thread.jspa?threadID=5271181)
Hi,
I've written a propositional logic grammar for a JavaCC parser that compiles fine.
JavaCC generates a SimpleNode class to represent the input. I have methods to be added to the SimpleNode class but would prefer to leave SimpleNode as untouched as possible incase the JavaCC grammar ever needs to be modified, which would lead to the SimpleNode class being regenerated and potentially overwriting the added methods.
So far to get around this I've created a 'SimpleNodeSuperclass' that SimpleNode extends, and put the extra methods inside SimpleNodeSuperclass instead.
I then intend to create a subclass of SimpleNode, called Sentence. Sentence will be where I put the logic methods eval(), isContradiction(), isTautology() etc.
So something like
public interface Node {
     // Generated by JavaCC
     // Contains generic Node operations - adding children, traversing the tree...
public abstract class SimpleNodeSuperclass {
     // Added by me
     // Contains a few extra bits needed in SimpleNode - setting a text label for example.
public class SimpleNode extends SimpleNodeSuperclass implements Node {
     // Generated by JavaCC
     // Implements operations required by Node.
public class Sentence extends SimpleNode {
     // Added by me
     // Contains logic operations
     public Boolean eval() {...}
     public Boolean isContradiction() {...}
     public Boolean isTautology() {...}
     // etc.
}I'm having problems when I try to create a new instance of Sentence though. Previously, to create a SimpleNode, I would do the following
PropLogicParser parser = new PropLogicParser(new StringReader("a & !b"));
SimpleNode root = parser.query();
root.dump();Which would output
Root
And
  Atom
  Not
   Atomas expected.
The problem seems to be that of the other JavaCC generated files refer to Nodes and SimpleNodes so the normal operations don't work with the 'Sentence' class.
I'm sure I'm just missing something obvious with my grasp of Abstract vs Interface vs Inheritance but my brain seems to have slowed to a crawl this evening :(
Cheers

>
I know diddly about JavaCC, but from what I read at https://javacc.dev.java.net/ it would appear that it generates some parser code, which in turn generates a parse tree, which you can may then manipulate.
>
That's about it, you drop a grammar in, it generates a parse tree based around SimpleNodes. There's a bit of smartifying needed, for example when you have "a & b" then it knows a and b are atoms, but you need to add a setLabel() method to capture their names so you can tell them apart. It's that method that's gone into the SimpleNodeSuperclass.
package parser;
abstract class SimpleNodeSuperclass {
     protected int id;
     protected String label;
     public void setLabel(String label) {
          this.label = label;
     public String getLabel() {
          return label;
     public void setType(int type) {
          this.id = type;
     public int getType() {
          return id;
}If I make a sentence have a parse tree then it introduces more problems from what I can see.
package logic;
import parser.SimpleNode;
public class Sentence {
     final private int     ROOT          = 0;
     final private int     VOID          = 1;
     final private int     EQUIVALENT     = 2;
     final private int     IMPLIES          = 3;
     final private int     OR               = 4;
     final private int     AND               = 5;
     final private int     TRUE          = 6;
     final private int     FALSE          = 7;
     final private int     NOT               = 8;
     final private int     ATOM          = 9;
     private SimpleNode     node;
     public Boolean eval(Interpretation inter) {
          Boolean val;
          SimpleNode lhs = (SimpleNode) node.jjtGetChild(0);
          SimpleNode rhs = (SimpleNode) node.jjtGetChild(0);
          switch (node.getType()) {
               case ROOT:
                    val = lhs.eval(inter);
                    break;
               case VOID:
                    val = null;
                    break;
               case EQUIVALENT:
                    val = (lhs.eval(inter) == rhs.eval(inter));
                    break;
               case IMPLIES:
                    val = (!lhs.eval(inter) || rhs.eval(inter));
                    break;
               case OR:
                    val = (lhs.eval(inter) || rhs.eval(inter));
                    break;
               case AND:
                    val = (lhs.eval(inter) && rhs.eval(inter));
                    break;
               case NOT:
                    val = !lhs.eval(inter);
                    break;
               case ATOM:
                    val = inter.get(getLabel());
                    break;
               case FALSE:
                    val = false;
                    break;
               case TRUE:
                    val = true;
                    break;
               default:
                    val = null;
                    break;
          return val;
}The eval() method is all well and good, but because a SimpleNode's children are SimpleNodes too then you can't recursively call eval() on the children without first defining an eval for type SimpleNode - and if I did that then there'd be no point making one for Sentence in the first place.
Again, the reason I don't want to edit SimpleNode directly is because it's generated by JavaCC.
What I did before was just have a completely separate class that only contained helper methods, so I'd just use
LogicOperations.eval(mySimpleNode, myInterpretation);
instead of
mySimpleNode.eval(myInterpretation);
package logic;
import java.util.*;
import parser.*;
public class LogicOperations {
     public static Boolean eval(SimpleNode root, Interpretation inter) {
          Boolean val = null;
          SimpleNode left = null;
          SimpleNode right = null;
          switch (root.jjtGetNumChildren()) {
          case 1:
               left = root.jjtGetChild(0);
               right = null;
               break;
          case 2:
               left = root.jjtGetChild(0);
               right = root.jjtGetChild(1);
               break;
          default:
               break;
          switch (root.getID()) {
          case LogicParserTreeConstants.JJTROOT:
               val = eval(left, inter);
               break;
          case LogicParserTreeConstants.JJTVOID:
               val = null;
               break;
          case LogicParserTreeConstants.JJTCOIMP:
               val = (eval(left, inter) == eval(right, inter));
               break;
          case LogicParserTreeConstants.JJTIMP:
               val = (!eval(left, inter) || eval(right, inter));
               break;
          case LogicParserTreeConstants.JJTOR:
               val = (eval(left, inter) || eval(right, inter));
               break;
          case LogicParserTreeConstants.JJTAND:
               val = (eval(left, inter) && eval(right, inter));
               break;
          case LogicParserTreeConstants.JJTNOT:
               val = !eval(left, inter);
               break;
          case LogicParserTreeConstants.JJTATOM:
               val = inter.get(root.getLabel());
               break;
          case LogicParserTreeConstants.JJTCONSTFALSE:
               val = false;
               break;
          case LogicParserTreeConstants.JJTCONSTTRUE:
               val = true;
               break;
          default:
               val = null;
               break;
          return val;
}It's entirely likely that I've missed what you were trying to say with the good ole 'has a' relationship ting Corlettk, let me know if so

Similar Messages

  • Inheritance / interfaces

    Hi
    If a subclass Y inherits (directly) from class X, which implements an interface A, should class Y implement the inferface too(I mean with the 'implements A' statement)? Or does class Y automatically implement the interface A and therefore, should it define the operations of the interface..
    Thanks in advance for a lightening answer.

    It seems to be like you say, but still then there is something I don't get.
    In fact, because a subclass inherits from the abstract class that implements the interface and(!) defines all the operations of the interface, in my view the implementation of the operations in the subclass shouldn't be necessary because of the inheritance of the operations.
    So to be short: the operations of an interface are not inherited in a subclass of a class where the interface is implemented but you should implement the operations of the interface in the subclass.
    Is this correct of am I wrong?
    I understand my vision is perhaps not very logic.. but I can't compile anything without defining all the operations of the interface in the subclasses.. even if I define all the operations in an abstract class 'above' the subclasses.

  • When should I use abstract classes and when should I use interfaces?

    Can any body tell me in which scenario we use /we go for Interface and which scenario we go for abstract class, because as per my knowledge what ever thing we can do by using Interface that thing can also done through abstract class i mean to say that the
    behavior of the two class.
    And other thing i also want to know that which concept comes first into the programming abstract class or Interface.
    S.K Nayak

    The main differences between an abstract class and an interface:
    Abstract
    An abstract class can contain actual working code (default functionality), and can have either virtual or abstract method.
    An abstract class must be sub-classed and only the sub-classes can be instantiated. Abstract methods must be implemented in the sub-class. Virtual methods may be overridden in the sub-class (although virtual methods typically contain code, you still may
    need/want to override them). A good use for an abstract class is if you want to implement the majority of the functionality that a class will need, but individual sub-classes may need slightly different additional functioality.
    Interface
    An interface only contains the method signatures (method name and parameters), there is no code and it is not a class.
    An interface must be implemented by a class. An interface is not a class and so it cannot be sub-classed. It can only be implemented by a class. When a class implements an interface, it must have code in it for each method in the interface's definition.
    I have a blog post about interfaces:
    http://geek-goddess-bonnie.blogspot.com/2010/06/program-to-interface.html
    (sorry, I have no blog posts specific to abstract classes)
    ~~Bonnie DeWitt [C# MVP]
    http://geek-goddess-bonnie.blogspot.com

  • What is the advantages of using Interface?

    Hi,
    I still don't get what's the advantages of using interface. Reusability? is it the main advantage? thanks in advance.

    What is GOF?
    Interface is a good program practice when working with RMI (Remote Method Invocation) application. Imagine your anti-virus. When you connect to internet your software invoke a method into your software vendor site and download the new definitions. Now every anti-virus Subscription is different. The method you invoke, will depends on your Subscription. If you hard code the method abstractly, you will not achieve this functionality.
    Another concept is that because Java does not practice multile inheritance interface is a goog way to interface into another class.
    Example
    I want to extends to multiple class which java do not support. I will write an interface i.e I want to extends to FileOutputStream, OutputStream, Object, Integer, String, ActionEvent, Window etc.
    I will write an interface like this
    interface MyClass {
    pulic void setFileOutputStream ( FileOutputStream file );
    public void setOutputStream ( OutputStream );
    public Object getObject ( );
    public Seriable getInterget ( )
    ------------------- //You get the gist
    With this interface you can implement they behaviours
    You could say, why don't we just import them. When yo import them you have already hard coded there behaviour. But this way you can apply diferent behaviour throughout you application development. And any class that implement them must provide ways of using it.

  • Question about multiple inheritance

    Why does java not support multiple inheritance, but also give you the ability to use interfaces?
    I've done a quick search on here which turned up the same thing as the books on java I've read - they tell me that java doesn't support multiple inheritance, and that it supports interfaces, but not why.
    And from what I can see, the between multiple inheritance and single inheritance + interfaces make them seem almost equivalent, especially when you consider abstract classes. So why did the java designers make this decision?
    Edit: Just to say I've never programmed in an OO language that supports multiple inheritance, so I've never had to deal with it. Also, single inheritance has never crippled any of my designs (not that there have been that many), I'm not whingeing, just asking.
    Message was edited by:
    Dross

    Why does java not support multiple
    inheritance, but also give you the ability to use
    interfaces?It does support MI, just not MI of Implementation.
    why.
    class Beasty { }
    class Horse extend Beasty {
       public void gallop() { System.out.println( "horse" ); }
    class Donkey extend Beasty  {
       public void gallop() { System.out.println( "donkey" ); }
    class Mule extend House, Donkey {
    Mule mule = new Mule();
    mule.gallop();what would this print out.
    MI of implementation makes life harder, but adds very little to the party. So why add it?

  • Interfaces Extending Interfaces Problem?

    Hey everyone,
    I have a problem that could effect anyone who is using interfaces that extends other interfaces.
    Check this out:
    If I have an interface IHuman that extends three interfaces IMortal, ILimbed and IHealth:
    package
         public interface IHuman extends IMortal, ILimbed, IHealth
    Extends
    package
         public interface IMortal
              function spawn():void;
              function die():void;
    package
         public interface ILimbed
              function sprint():void;
              function walk():void;
              function crouch():void;
    package
         public interface IHealth
              function set health( value:Number ):void;
              function get health():Number;
    Now when the code is generated for the Human class when the IHuman interface is implimented, CHECK THIS OUT!
    package
         public class Human implements IHuman
              public function Human()
              public function spawn():void
              public function sprint():void
              public function set health(value:Number):void
              public function die():void
              public function walk():void
              public function get health():Number
                   return 0;
              public function crouch():void
    The functions are all over the place, it becomes an interface pasta! Now, I dont know if there is a preference for this. But I have been looking all day, and I have found no solution to this code generation problem.
    This is not helpful code generation, it simply throws the interfaced functions around in your class, and becomes a real hastle to re-organize.
    Does anyone have a solution to this really odd code generation problem?
    Cheers
    Nick

    My question is not to inherit the interface or not. It is about the generation of code from an inherited interface. Why is it that when I inherit an interface that exdends other interfaces, that it does not generate the code in order of the extended interfaces.
    My question is basicaly this, why does the inherited interface get interwoven with it self when I impliment it in a class.
    package
         public interface IMortal
              function spawn():void;
              function die():void;

  • Finder list view difficulty

    I prefer to use the List View in the Finder but I find one aspect of this interface particularly annoying. That is, if an item is highlighted (as it usually is) and one needs to scroll down or up to locate another item, the Finder keeps returning the focus to the item that is highlighted. This can be improved by pressing the escape key (to un-highlight the original item) but I usually forget to do this until the offending refocusing has already occurred. Does anyone have a workflow or suggestion as to how to avoid this problem.
    OK, I know this sounds trivial but I am a developer who uses the Mac for several hours a day and am constantly locating code files in deeply embedded folder structures (probably several hundred times a day). I am hoping to smooth out this user interface experience.

    Sorry, no, preferences in the sense of what I prefer, but I believe view options (command J) are stored in DS_Store files, as well as list view column data, such as date added, date modified, name, kind, size, etc (except for some folders such as network, computer and meetingroom/airdrop?) which are stored in com.apple.finder.plist).  You probably know that you can select which columns display in view options.  Perhaps a temporary workaround would be to switch off other visible columns to display only name or name and one other preferred column to increase space available.  However, myself and another suspect this the problems I described as a bug, and I would have to think your issue is part of that bug.  It seems all related, no? For example, in my Downloads folder, I select to hide "Date Modified", show "Date Added", and arrange by "Date Added".  Maybe it will still show if I close the window and reopen the Downloads folder, maybe it will not, maybe it will change completely to Icon View despite have "always open in list view" being selected in view options.  In any case, after a restart, it will revert back to list view, with "Date Modified" showing and being arranged by "Name".
    Sent feedback to apple, maybe will help if you do as well:
    Mac OS X - Feedback

  • How can I copy the name of a file, that I selected by a click?

    Hi,
    I have a device controled by a Excell (VBA) interface. Truogh this interface I control the motors and Diadem (for the report) and the data are save in a database. When I  use the load button from the excell, the VBA application call the script from Diadem  Load_DATA_BOF.VBS, (after I complete the new data for the report), and make the report.  Now to make it work, I copy the name of the filename that I want to load in a TextBox, and all the data are store in a txt file( protocol_for_load.txt) and Diadem takes from there the data for the report.
    What I want to do is to fill automatic the field of the filename in the  protocol_for_load.txt, when I select the file in  Diadem.
    Can this be done?
    Thank you for your time
    Solved!
    Go to Solution.
    Attachments:
    BOF script.zip ‏177 KB

    Hi Brad,
    I find out how to copy the name of a selected file ( with filedlgfile) and now I want to open the text file ( with the name the same like the file loaded)  so I can read the data from inside, but the command textfileopen from the script can't support a variable in the description, I thing.
    Fno = textfileopen ( filenametxt, tfread)
    Please look in to my script to understand better.
    I need to open the txt file with the name the same like the file loaded, to take the data and fill the report. This I need to do in Diadem Script, because I will call the script trough a VBA interface.
    Sorry for not being more clearly  first  time, but I am a beginner in working with VBS.
    Attachments:
    Diadem script.zip ‏69 KB

  • Outsourcing of Benefits to 3rd Party

    Hello... we are currently using the SAP HR Benefits module, but will soon be outsourcing our HR Benefits administration to a 3rd party.    The 3rd party will be sending us the benefits deductions via an interface, so that we may incorporate them into our SAP Payroll run.   My question is the following:   is it better to store the benefits deductions on infotype 14, or does it make sense to continue to configure SAP HR Benefits and store the deductions on the benefits infotypes utilizing the 'alternative cost' field?    Opinions welcome...thanks.

    Hello Linda,
    Since the third party will be sending you the benefits deductions via an interface, it would seem logical to me to transfer them directly into IT0015, every pay or every month(according to your needs).
    As for the configuration of Benefits in SAP, you could keep it in place and comment out functions P0167 and P0168 in your schema.  If you want to be able to generate reports on enrollments, it would be preferable if the information could be maintained in SAP (perhaps an other interface).
    Sorry for the late answer but I just noticed your thread.
    And for SapUser1204, you should identify your needs (requirements) before trying to define the interface parameters.
    When you have identified these needs, please open your own thread.

  • I want to find the digital audio output on my Pavilion vd6853ea notebook

    I have spent far too long trying to find where this output is located.
    I have a very good Hifi and at the moment am using a USB cable to connect to my DAC.
    It looks like there is a realtec digital output somewhere on the notebook as it show up when I go into the playback devices and it tests ok visually.
    The 3.5 jack plug is just analog and not a hybrid spdif.
    Where is it????????
    Please help as I am getting really fed up now!
    This question was solved.
    View Solution.

    HI,
    macapaca666 wrote:
    Thank you so much for the fast reply.
    I thought that may have to be the case.
    Can I please ask you a few other questions?
    If I want to get a digital audio output not using a HDMI (My DAC doesn't have this input), can I get a good result with something like a Musical Fidelity V link USB to S/Pdif converter or a M2Tech Hiface digital audio interface? Sorry,  I cannot make a recommendation on either of those products as I am not familiar with them. 
    Is it possible to change the sound card with an optical or coaxial output? Your notebook's sound is an integrated solution. It is a chip soldered (integrated) onto the system board. It can't be updated.
    Thanks again for the kind help!
    John
    Best regards,
    erico
    ****Please click on Accept As Solution if a suggestion solves your problem. It helps others facing the same problem to find a solution easily****
    2015 Microsoft MVP - Windows Experience Consumer

  • How best to handle hundreds of similar objects?

    Hi. I'm a relative newcomer to Java. I've been working on an application that involves a table of data. Each column in the table represents a different type of data. The data can be numeric, dates, Strings, etc. If I were to create an interface describing the charcteristics that each implementation of a column should have, it would be something like:
    getTitle();
    getDataType();
    getDefinition; //some columns will require explanation (maybe via tooltip or dialog box)
    getValue; //could be simple as pulling a value from a database or could be complicated code
    getDependencies; //identify what other columns may be required to be present in order to calculate getValue();
    getSettingsDialog(); //return JDialog with a custom control panel for the particular column (may include formatting, calculation parameters, etc.)
    etc.
    etc.
    So, the quesiton I'm struggling with is that if in the long run there may be hundreds of unique columns, is it better to create a separate class for each column, or create one class and just parameterize everything. It seemed odd to me to create hundreds of similar classes, so I started out creating one class and creating new instances for each column needed. But, if you do that, how do you store stuff like the code needed for certain methods? For example, the calculations in getValue() could involve lengthy code. Do I just store all of the various getValue() code in one big static class that the column instance would look up or call? Or should I just switch to creating a new class for each column I need (all obviously deriving from the same abstract class/interface)?
    Sorry if this isn't clear. I have been reading through various OOPS and design pattern books, but haven't found anything that clears this up definitively. Thanks.

    Bob.B wrote:
    Some of the data comes from a database, but a lot of it is then derived from that data. There really can be hundreds of columns. The data I'm dealing with is kind of esoteric, so I'll try to describe the situation with a more common set of data. Imagine you were lucky enough to own McDonalds (the whole company) and you wanted a view of how all of the franchises were doing (the franchises would be the rows in the table). Each franchise will have hundreds of characteristics about it stored in some database (e.g. owner, address, city, state, date opened, total hamburger sales each day, total milkshake sales each day, etc. etc.). The application is essentially a treetable that allows the user to 1) pull whatever franchises he wants based on user criteria, 2) group and subtotal the franchise data on any available field (e.g. group and subtotal franchise data by city), and 3) choose what data (i.e. columns) is displayed.
    "Treetable" is a GUI item. You probably shouldn't be pulling the entire dataset, but rather pulling it at once.
    The data structure can drive the GUI but it probably shouldn't be the sole driving factor. Unless the only goal is to drive a reporting engine. See below.
    If the columns merely pulled the data as is from the database, it would be pretty straightforward to just have one column class that knows which db field to pull and then display. But, imagine that there are many more potential columns that get a little bit more complicated. For example, there may be standard metrics that are not directly stored in the database because they can be derived. For example, hamburger sales per store, hamburger sales per day for each day of the week, the ratio of hamburger sales to milkshake sales, etc. Anyway, with the data I'm dealing with, these calculations can get quite complex and there are actually many, many standard metrics that the user would want to see. There are also aspects of the data that the user would want to control on the fly (i.e. have access to column by column settings).
    Presumably you are carefully controlling the data calculation. If it pulls a number today for last weeks data it must be able to pull that same number next year even if how the result is calculated changes later this year.
    So, I think it makes sense for the columns to each be separate objects. I started by having one column class, and when I needed a complicated getValue() function in it, I just stored the calculations in one giant static class that has all the various calculations, and I access the appropriate calculation in that class with a switch statement. I just wasn't sure if this was the most efficient way to do it. It would be easier for me to just have a separate class for each column (all with the same interface), but I didn't know what the overhead in Java was to have hundreds of distinct classes.
    Sounds like a report to me. One layer encapsulates real data. Another layer encapsulates reporting. Values that appear on reports are either data or they are calculated from the data. Notice the the report layer, not the data layer, does the calculation.
    Keep in mind that the calculations themselves might be data driven but by their own data layer. This can include parameters of the calculation, like sales tax for the given period, or the calculation itself (for instance by keeping the algorithm as a java class in the database.)
    Also note that reporting (which includes more that printed reports) is not new and there are commercial and freeware frameworks for it.

  • Are Multiple Classes with Same name in a single Class valid ?

    package inheritance;
    interface Foo
         int bar();
    public class Inh6 {
         class A implements Foo  // THis is the first class
              public int bar()
                   return 1;
         public int fubar(Foo foo)
              return foo.bar();     
         public void testFoo()
              class A implements Foo // THis is the second class
                   public int bar()
                        return 2;
              System.out.println(fubar(new A()));
         public void testFooModified()
              class A implements Foo // THis is the first class
                   public int bar()
                        return 4;
              System.out.println(fubar(new A()));
         public static void main(String[] args) {
              new Inh6().testFoo();
              new Inh6().testFooModified();
    O/P :
    2
    4My question is this class "A" which is present in the different methods like testFoo() and testFooModified() different declarations of the same class or altogether different classes local to each method,something like err...Local Class ?
    Thanks in Advance.

    kajbj wrote:
    My question is this class "A" which is present in the different methods like testFoo() and testFooModified() different declarations of the same class Why would it be the same class? They have different scopes.
    KajSo you mean to say they are actually different classes with the same name,which will be invisible out of the respective methods in which they are defined ?
    Thanks.

  • Class-data versus data and methods versus class-methods in OO ABAP

    Hi
    I was going thorugh following OO ABAP code.
    CLASS vessel DEFINITION.
      PUBLIC SECTION.
        METHODS: constructor,
                 drive IMPORTING speed_up TYPE i,
                 get_id RETURNING value(id) TYPE i.
        CLASS-METHODS: start,
                       objects,
                       inheritance,
                       interfaces,
                       events.
      PROTECTED SECTION.
        DATA: speed TYPE i,
              max_speed TYPE i VALUE 100.
      PRIVATE SECTION.
        CLASS-DATA object_count TYPE i.
        DATA id TYPE i.
    ENDCLASS.
    Whats is difference between methods and class-methods ?
    What is the difference between data and class-data ?

    Hi Rajesh,
    There are two types of componenets in a class
    1)Static components
    2) Instance components
    Instance components exist for every instance of the class, while static exist only once for any number of instances of the class.
    Components of the class are methods, attributes, events etc.
    static attributes are represented by CLASS-DATA and instance attributes are represented by DATA.
    static methods hence are done by CLASS-METHODS and can access only static attributes.
    Instance methods are done by METHODS and can access any attribute.
    For eg: supposing that in a class, there is a static attribute. Suppose after one instance is created, we are setting this static attribute value as 10. Now we are creating another instance of the same class. Now when you try to display the value of this attribute, it will be 10.ie. it needs to be initialized once and can be shared between instances.
    Just go through this document..You will get nice info from this.
    http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    If you want to go deeper, like object persistence and all, just refer this document.
    http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    Regards,
    SP.

  • Create a folder with permissions set to This Folder, subfolders

    Basically my app creates 4 folders that gives a specific user certain permissions.
    I can create the folder find, and i can give the user the correct permissions, but by defaulse it has Apply To set to this folder only, so if the user creates a folder, they wont have permissions to access it.
    I want to give it permissions that Apply to: This folder, subfolders, and files.
    I have spent hours upon hours trying different things, and trying to find the answer anywhere. Any help is greatly appreciated.
    Here is my code to create the folders:
    string mailDataPath = "E:\\Data\\MailData\\" + logonName;
    string userDataPath = "E:\\Data\\UserData\\" + logonName;
    string userProfilePath = "E:\\Data\\UserProfile\\" + logonName;
    string userSharedPath = "E:\\Data\\UserShared\\" + logonName;
    path[0] = mailDataPath;
    path[1] = userDataPath;
    path[2] = userProfilePath;
    path[3] = userSharedPath;
    //If folders do not exists, create them.
    for (int x = 0; x < pathAmount; x++)
    if (!Directory.Exists(path[x]))
    Directory.CreateDirectory(path[x]);
    //Sets folder permissions dependant on which folder it is
    if (path[x] != userProfilePath)
    DirectoryInfo info = new DirectoryInfo(path[x]);
    DirectorySecurity security = info.GetAccessControl();
    security.AddAccessRule(new FileSystemAccessRule(logonName, FileSystemRights.Modify, AccessControlType.Allow));
    info.SetAccessControl(security);
    else if (path[x] == userProfilePath)
    DirectoryInfo info = new DirectoryInfo(path[x]);
    DirectorySecurity security = info.GetAccessControl();
    security.AddAccessRule(new FileSystemAccessRule(logonName, FileSystemRights.FullControl, AccessControlType.Allow));
    info.SetAccessControl(security);

    Figured it out. It wasn't as difficult as i made it out to be.
    I just need to use 2 access rules
    DirectoryInfo info =
    new
    DirectoryInfo(path[x]);
    DirectorySecurity security = info.GetAccessControl();
    security.AddAccessRule(new
    FileSystemAccessRule(logonName,
    FileSystemRights.Modify,
    InheritanceFlags.ContainerInherit,
    PropagationFlags.None,
    AccessControlType.Allow));
    security.AddAccessRule(new
    FileSystemAccessRule(logonName,
    FileSystemRights.Modify,
    InheritanceFlags.ObjectInherit,
    PropagationFlags.None,
    AccessControlType.Allow));
    info.SetAccessControl(security);
    this is the code for the setting of the permissions.
    had to play around with it a bunch to get the correct inheritance.
    Im sorry i dont realy understand. Where do i put this code? Is there a guide for were to put this? Thanks for your help! :)

  • CRM_BSP_SURVEY giving CX_SY_REF_IS_INITIAL error

    Hi,
    I have to use the survey BSP Application in IC Web UI.
    But while testing the the BSP Application we are getting an error
    Exception Class CX_SY_REF_IS_INITIAL
    Error Name 
    Program CL_CRM_BSP_SURVEY_SC==========CP
    Include CL_CRM_BSP_SURVEY_SC==========CM001
    ABAP Class CL_CRM_BSP_SURVEY_SC
    Method DO_REQUEST
    Line 12 
    Long text An attempt was made to execute a dynamic method callon an initial(NULL-) object reference. The reference must refer to an object.
    while debugging we can see that the problem we are facing is
    data: lr_main_controller   type ref to if_crm_bsp_parent_com.
    *lr_main_controller ?= m_parent.*
    the lr_main_controller is always initial and its not getting populated.
    Any suggetsions to resolve this issue.
    Regards,
    Sijo.
    Edited by: sijokjohn85 on Oct 5, 2009 4:56 PM

    Hi keps31,
    if this happens (why did you not tell us????????) in an XI/PI interface, it is probably a customizing error. I remember in the proxy configuration you assign classes to the inbound message which are used for the inbound processing.
    If the class does not exist, system  can not create an object and invok the processing method.
    Check your interfaces. Sorry I don't have the details for you, but you also don't give the details to us.
    In the dump, the active programs are listed.
    Regards,
    Clemens

Maybe you are looking for