I'm confusing about this point since almost all DOM nodes are some sub-interface of the Node interface, but I can't find the precise definition that can prove this. Is there anybody know more about this? thanks.
Yes, all nodes inherit from the DOM Node interface:
The following interfaces all inherit from Node’s methods and properties: Document, Element, CharacterData (which Text, Comment, and CDATASection inherit), ProcessingInstruction, DocumentFragment, DocumentType, Notation, Entity, EntityReference
And also, according to W3:
The Node interface is the primary datatype for the entire Document Object Model. It represents a single node in the document tree. While all objects implementing the Node interface expose methods for dealing with children, not all objects implementing the Node interface may have children. For example, Text nodes may not have children, and adding children to such nodes results in a DOMException being raised.
Related
I made a concurrent system which has a critical section which involves read and write access to a TXT file.
First, an Auctioneer class creates a TXT file and writes the number 50 to it. The Auctioneer then allows the next node, one of three instances of the Bidder class, to open the file and change the current bid. The bidder class then allows the next node, another bidder to bid, then another bidder, and then that bidder allows the Auctioneer to look at the file.
I allowed the nodes to take turns using server sockets. Each node waits for access using the ServerSocket.accept() method, and allows the next node to enter its critical section by creating a Socket object with the socket that ne next nde is listening on.
Each of these nodes run independantly in seperate java environments and only communicate with server sockets.
Each node of the ring relies on the previous node because in order for that node to access the resource, the previous node needs to pass the current node the token. I'm unsure on how I would represent that kind of relationship in a UML compliant way.
It is of my understanding that class diagrams should not include several instances of the same class such as the example below with 3 bidders.
Is this the correct way to represent the relationship which I have described? If not, which way would be better/UML compliant?
Class diagrams, as the name suggest represent classes of objects and not individual objects, i.e. instances of these classes. Moreover, a class diagram is structural: it does not tell how objects interact or wait one for another, but how classes relate.
In tour case the class diagram would therefore represent one bidder class. To represent a concrete example with instances and how they relate, you could consider an object diagram. There you could very well represent different instances of the same class.
However, if you’re interested in the interactions between classes (e.g. the tokens they exchange), you’d better consider an interaction diagram such as the sequence diagram.
Is there a way to modify a JCR node, but keep its jcr:lastModified and jcr:lastModifiedBy properties unchanged?
And by modifying, I mean via the JCR API. For example:
aNode.setProperty("propName", aValue);
It is possible for the most cases. There are basically two options how a node retrieves both properties and get's them updated.
Either through some higher level API like CQ's PageManager, which is applying it on the jcr:content node or by the repo if the node has the mixin type mix:lastModified in it's type hierarchy.
[mix:lastModified]
mixin
- jcr:lastModified (DATE) autocreated
- jcr:lastModifiedBy (STRING) autocreated
In this case the properties are automatically managed through the repository.
So you should be fine, as long as you avoid to create nodes with the mentioned mixin in it's type hierarchy e.g. nt:resource.
Currently we have a structure like the following in our UML Class Diagram:
Node --1------------*-- Data
^ ^
| |
SpecialNode--1----*--SpecialData
E.g. SpecialNode is a specialization of the class Node and SpecialData is a specialization of the class Data.
The idea is that each SpecialNode only has SpecialData, and no 'normal' Data.
However, some would argue that since a SpecialNode is a Node, it can have relationships to both Data and SpecialData.
Is there any reference material available that would clarify if SpecialNode can have only SpecialData? If not, how could we inforce this (in a clean way).
Kind Regards,
Joos
Indeed, such modeling implies that SpecialNode inherits all the properties of Node, including Data. Otherwise it would contradict the Liskov Substitution Principle which is an important rule for good design. I would suggest not to define your Node and SpecialNode as "having" Data or SpecialData but rather have an interface to Data. For Node it will be associated with Data object and for SpecialNode it will be associated with SpecialData object.
So I'm new to the concept of routed events, but I know that messages are flying everywhere when fields are changing via the RaiseDataMemberChanging / RaiseDataMemberChanged messages.
The quick question is how to I "listen" for those routed messages?
I would like my view model, in a MVVM correct matter, intercept a message that a field is being updated, deep down in the heirarchy of tables. If a change occurs in a child (a date range), that date range change has some business logic associated with it that works from top down.
I've know that I can use partial methods to inject code during the changing and changed events, but the design (one to one relationship) means that a change to the child, in the context of the child, has no reference the parent (Parent has a one to one reference to child, but child has no reference to parent).
Yes I can add the reference from the child to the parent (making the parent have both a one to one, as well as a one to many relationship), but during creation of the entity, this creates a problem - parent has to exist before the child entity exists, and the child entity has to exist before a reference to the parent can exist. This design requires an insert of the parent, and child, then an update of the child - which confuses WCF RIA Services during the inital creation process.
Sorry for the long winded explaination, but I'll even consider design changes if this all makes sense to anyone that cares to comment.
Any input would be appreciated.
I'm using a subscription to the PropertyChanged events of the Entity in question. It seems like a lot of work to filter out all the events for a couple of fields.
Using RX, I'm hoping that the resources used are minimal, and the weak reference avoids the memory link issue when a strong reference is used to deal with events:
Observable.FromEventPattern<PropertyChangedEventArgs>(this.FlowEntity, "PropertyChanged")
.Where(pPropertyChanged => (
pPropertyChanged.EventArgs.PropertyName.EndsWith("Date")) ||
pPropertyChanged.EventArgs.PropertyName == "Capacity"
)
.Subscribe(pObserver => this.RaiseFlowEntityDateChanged(this, pObserver.EventArgs));
FlowEntity is the child entity that I'm monitoring from the parent. I then raise custom event using the parent entity, rather than the entity that actually holds the event.
I can't raise this event from the partial methods, as the child entity would not have the context of the parent.
Class Engine has "start(c:Component)" method. So do we need to draw an association between Engine and Component Class IF there is no "new Component()" inside Engine class.
No, you do not in general need to have an association to a type even if the type is mentioned in a parameter. It entirely depends on if the state of an Engine maintains a relationship with one or more Components.
If the Component you passed around is only use locally in method start, then there is no real association that persists from one state (one method call) to the next.
This is not an association, it´s a dependency relationship between the two. A dependency means that if the dependee (the Component in your case) changes the depender (the Engine) may become affected (maybe Engine::start was using a Component method that it is no longer available or that has changed its parameters)