I read through the DOORS Reference Manual but couldn't find a simple insert method. I'm looking to insert an object, which was created within my DXL script, into a module.
I was hoping to find something intuitive like
insert_object_after(Module m, Object o, string object_identifier)
which would scan the module for the specified object identifier and insert the object after finding that identifier. Does such a function exist? If not how could I go about performing the action I've described?
Some basic example code would be awesome.
Chapter „Object management“. Use one of the commands
Object create(Module m)
Object create(Object o)
Object create(after(Object o))
Object create(before(Object o))
Object create(below(Object o))
Object create(first(below(Object o)))
Object create(last(below(Object o)))
For these functions, you need a variable of type Object. There are several ways to fill such a variable, look at the chapters „Finding objects“ and „Navigation from an object“. Probably the easiest way would be to use the function Object object(int absno[,Module m]) (with absno being the absolute number of the „source“ object. But beware that object only works if the current filter allows to navigate to this object, so, if the function "Go To“ from the menu works in your current view with your source object, then object should work as well
Related
I am very confused about something and I would appreciate some insight here.
Say I want to build a GUI that visualizes what is going on inside JShell, i.e. how the, by snippets created objects reference each other and what, by Snippets created objects are contained inside my running instance of JShell. How do I access these objects, and most of all, how do I access how they reference each other?
A concrete example: I create a JShell instance, pass it a few snippets created by the user, which cause the creation of, for example, an ArrayList, a few objects, and add said objects to said ArrayList.
How do I access this ArrayList and the objects contained within it to visualize this in a GUI?
To clarify further:
//say I create a Jshell:
JShell jShell = JShell.create();
//Which then evauletes user code passed from the GUI:
jShell.eval(userCode)
//userCode could be following lines each passed as separate Strings:
“ArrayList<TestObject> allObj = new ArrayList<TestObject>();”
“TestObject tst = new TestObject();”
“TestObject tst2 = new TestObject();”
“allObj.add(tst);”
“allObj.add(tst2);”
How do I access “allObj”?
How do I access “tst” and the object it points to? (the “TestObject”instance that “tst” points to);
I know eval() returns a list of SnippetEvents which contain the changed/added snippets, however, I can’t get my head around how to access the objects created by those snippets.
Assuming your classpath has access to the TestObj you could implement Serializable on that object. Upon completion of the eval run another method automatically that serializes the output. Then you can deserialize that object inside your code.
I'm trying to create a MutableProperty which holds a Results received from Realm.objects(_:).
To create the property I need to give it an initial value; hence an 'empty' Results.
I've tried creating one using:
var someThings = Results<SomeObject>()
MutableProperty(someThings)
But the compiler gives me the error: Cannot invoke initializer for type 'Results<SomeObject>' with no arguments.
While I understand the error, I'm not really sure how to create a Results object in this context.
Looking at the source of Results I couldn't find an init either.
So my question is; how can I create a Results myself to use in a MutableProperty?
Edit:
I've seen this question...but that doesn't really help (unless I'm going to create a "wrapper" for the MutableProperty or something).
With help of the comments on my OP; I created a mutable property with an empty set of results by fetching objects with an 'invalid' filter.
E.g. MutableProperty(realm.objects(SomeObject.self).filer("EMPTY SET")).
I have an question about binding:
I have an array of objects of my custom class: Array. Every object can be updated (change his properties value) in bg.
Also I have separated Controller, which take and store one object from list as variable and can update it (object still the same, so in list it will be updated too)
Is there any way to bind all object.property -> UILabels on Controller in way, when property changes automatically call label update?
Of course, there are multiple ways how to do it, but from your description I would use some kind of subject (because u said there will be changes in background so you will probably need hot observable )....For example Variable or PublishSubject. So you can crate
let myArrayStream: Variable<[MyObject]> = Variable([])
you can pass this variable as dependency to wherever you want, on one side you can subscribe to it, on the other side you can update it's value.
I understand how to retrieve data from an XML source using type providers. However, I need to then modify a particular part of the XML and save it to disk. I have tried assigning a value to the node using <- but the property is read-only.
For example:
let doc = MyXml.load fileName
doc.ItemId.Id <- "newId" // doesn't work
doc |> saveXml
There is a similar question for JSON where the suggestion is to create a new object, but this is specifically for XML.
While researching my question I found that you can use the .XElement accessor to get a reference to a mutable XElement object. Thus a solution is:
let doc = MyXml.load fileName
doc.ItemId.XElement.Element(XName.Get "Id").Value <- "newId" // tada
doc.XDocument.Save(...)
Note that you have to use the .XElement accessor on the parent if you're modifying a leaf node. This is because the leaf node's type is a primitive and doesn't have an .XElement accessor of its own. A slight shame, but I suppose it makes life easier on the other side when you want read-only access to the value.
I was asked this question during my interview "How to create Linkedhashset using Hashset ?" anyone knows the answer ?
The LinkedHashSet class has a public LinkedHashSet(Collection<? extends E> c) constructor, so you could do
HashSet<Foo> hs = new HashSet<Foo>();
// add items...
LinkedHashSet<Foo> lhs = new LinkedHashSet<Foo>(hs);
to get a LinkedHashSet instance with the same content as hs. Note that there is no guarantee that the items from hs are inserted into lhs in the same order they were inserted into hs, since that information was never saved by hs.
There is no way to make "an HashSet which behaves like LinkedHashSet", that is, an instance of runtime class HashSet that behaves like a LinkedHashSet instance. However, you could do
HashSet<Foo> hs = new LinkedHashSet<Foo>();
which would give you an instance that would be seen by the outside world as a plain HashSet but use the LinkedHashSet implementation internally. I fail to see why you would ever want to do that, though - you would only gain a bunch of overhead and no added functionality, since the declared type is HashSet. The reason you'd want to use a LinkedHashSet in the first place is to be guaranteed the predictable iteration order, but you still wouldn't be able to assume that for hs - you could assign hs = new HashSet<Foo>() at any time, for instance.